Skip to main content
kerlinc3558
July 26, 2023
Question

Error Evaluating UI Expression

  • July 26, 2023
  • 4 replies
  • 0 views

Hello.

I am getting the following error when attempting to import an excel workbook into Appian.

From the Debug screen

Error Evaluating UI Expression
Expression evaluation error [evaluation ID = 168eb:f0c68] in rule 'excel_import' at function a!fileUploadField [line 6]: Error in a!forEach() expression during iteration 1: Expression evaluation error at function a!multipleFileUploadField_getEvalFileName [line 41]: Unexpected number of parameters.

From the Interface screen (FYI... I do not have a Line 41)

Could not display interface. Please check definition and inputs. Interface Definition: Expression evaluation error at function a!fileUploadField [line 6]: Error in a!forEach() expression during iteration 1: Expression evaluation error at function a!multipleFileUploadField_getEvalFileName [line 41]: Unexpected number of parameters.

a!formLayout(
label: "Import Excel Details Report",
contents: {
a!sectionLayout(
contents: {
a!fileUploadField(
label: "File Upload",
labelPosition: "ABOVE",
value: ri!ExcelData,
saveInto: ri!ExcelData,
target: cons!Excel_imported_files_pointer,
fileNames: "Excel Data " & now() & " " & user(),
validations: {}
)
}
)
},
buttons: a!buttonLayout(
primaryButtons: {
a!buttonWidget(
label: "Import",
submit: true,
style: "PRIMARY"
)
},
secondaryButtons: {
a!buttonWidget(
label: "Cancel",
value: true,
saveInto: ri!cancel,
submit: true,
style: "NORMAL",
validate: false
)
}
)
)

4 replies

stefanhelzle0001
Brainy
July 26, 2023

I think that this line is the issue

fileNames: "Excel Data " & now() & " " & user(),

The error message you see comes from the internal implementation. You try to call the user() function without passing any value. That will not work.

mikes0011
Brainy
July 26, 2023

That's a strange error message.  I noticed the issue with "user()" right around the same time I saw stefan's comment beat me to it (drats!) - i think you might be looking for the "loggedinuser()" function, which returns the current viewer's username.

Further, I believe the "fileNames" parameter requires an array, unless you're limiting the upload field to a single file (which you have not done).  And I would note that you're overwriting the original file's name (which you may intend to do), but also, "now()" will assign some characters (forward slashes, colons, etc) to the filename which will not be compatible with files that you want users to download back to their system (in case that's relevant in this case), so I'd suggest you sanitize that before including it in a filename.

The Expression Guru
harshm4411
July 27, 2023

In file name parameter you had used user() in which two parameters: "property" and "username" should be present. Including these two parameters when calling the function is essential for its proper functionality.

For Example:
user(username: loggedInUser(),property: "firstName")

Add these parameters then it will work perfectly.

kerlinc3558
July 27, 2023

Thank you all for the help. Every suggestion worked.