It report error with this which have been hinder me for couple days.
Interface Definition: Expression evaluation error at function a!queryLogicalExpression [line 25]: The a!queryFilter function has an invalid value for the "value" parameter. When the value of "operator" is "=" "value" must not be null or empty.
a!localVariables( a!formLayout( label: "Username", contents: { a!textField( label: "username", labelPosition: if( ri!readOnly, "ADJACENT", "ABOVE" ), value: ri!username.username, saveInto: ri!username.username, refreshAfter: "UNFOCUS", validations: { if( a!queryEntity( entity: cons!usernameConstant, query: a!query( fetchTotalCount: true, pagingInfo: a!pagingInfo( startIndex: 1, batchSize: 1 ), logicalexpression: a!queryLogicalExpression( operator:"OR", filters: { a!queryFilter( field: "username", operator: "=", value:(ri!username.username) ), a!queryFilter( field: "username", operator: "is null" ), } ) ) ).totalCount > 0, "Username exists", null ) } ), a!textField( label: "gender", labelPosition: if( ri!readOnly, "ADJACENT", "ABOVE" ), value: ri!username.gender, saveInto: ri!username.gender, refreshAfter: "UNFOCUS", ), a!columnsLayout( columns: { a!columnLayout( contents: { a!textField( label: "Password", labelPosition: if( ri!readOnly, "ADJACENT", "ABOVE" ), value: ri!username.password, saveInto: ri!username.password, characterLimit: 255, readOnly: ri!readOnly ) } ) } ), }, buttons: a!buttonLayout( primaryButtons: { a!buttonWidget( label: "Insert", saveInto:( a!writeToDataStoreEntity( dataStoreEntity: cons!usernameConstant, valueToStore:(ri!username) ), ), submit: true, style: "PRIMARY", ), a!buttonWidget( label: "update", saveInto:( a!writeToDataStoreEntity( dataStoreEntity: cons!usernameConstant, valueToStore:ri!username, ), ), submit: true, style: "PRIMARY" ), a!buttonWidget( label: "delete", saveInto:( a!deleteFromDataStoreEntities( dataToDelete: { a!entityDataIdentifiers( entity: cons!usernameConstant, identifiers:{ri!username.username}, ) } ) ), submit: true, style: "PRIMARY" ) }, secondaryButtons: { a!buttonWidget( label: "Cancel", value: true, saveInto: ri!cancel, submit: true, style: "NORMAL", validate: false ) }, showWhen: or( isnull( ri!readOnly ), not( ri!readOnly ) ) ) ) )
Discussion posts and replies are publicly visible
First two questions.
Why do you use a!localVariables with declaring a local variable?
In line 31: What are the parenthesis for?
As this is about a validation, I would put the existing if() in line 16 inside another if statement which checks whether there is any value entered. Then do the query only if there is an actual value. Then remove the second filter.
a!localVariables( local!insert:false, local!update:false, local!valid:if( ri!username.username in cons!usernameConstant, true, false),
if i want to validate different ways as above, then
"Invalid number of parameters, function 'if' requires an odd number of parameters, passed 4."
local!valid:if( ri!username.username in cons!usernameConstant, true, false),
"in" is not valid Appian syntax. You already tried that in another post.
May I suggest to read the documentation and attend some trainings?
i appreciate your help in recent couple of days, but my development team have no person sophisticate in appian, and i am the only person develop those of things, and for validation part for non duplicate value is a little bit urgent.
Try this
validations: { if( isnull(ri!username.username), {}, if( a!queryEntity( entity: cons!usernameConstant, query: a!query( fetchTotalCount: true, pagingInfo: a!pagingInfo( startIndex: 1, batchSize: 1 ), filter: a!queryFilter( field: "username", operator: "=", value: ri!username.username ), ) ).totalCount > 0, "Username exists", null ) ) }
Didn't post up "Username exists", and i want to add some prevention action such as disable the button for duplicate mistake.
Unknown said:Why do you use a!localVariables with declaring a local variable?
Did you mean to say without declaring...?
Indeed :-)
If i'm not remembering incorectly, validation code won't even attempt to run when the value of the field is null. I believe the null check layer of the nested IF() is thus unnecessary. If it's still causing errors due to it trying to execute in the background or something, then Harsha's earlier suggestion of using applyWhen should be the way to go AFAIK.
There are ways to disable the button when this condition is met, but in your case it should be unnecessary because, when configured correctly, a failed validation should prevent the user from clicking the submit button.
Cool - just wanted to make sure I wasn't missing something :)