Hello, again.
This is a strange one.... and I'm on version 24.1.281.0
I have two expression rules... one generates some error messages (or none) and the other deals with the errors. However, in the scenario where the first expression rule generates no errors, the second one still thinks there are errors.
Expression 1: (called SH_ErrorGenerator)
a!localVariables( local!stringArray: {"a", "b"}, local!error1: "", /* value from another expression rule normally */ local!error2: "", /* value from another expression rule normally */ local!error3: {""}, /* value from another expression rule normally */ local!errors: { local!error1, local!error2, local!error3 }, local!allErrors: cast( /* make sure this is list of string not list of variant */ typeof(local!stringArray), reject(a!isNullOrEmpty, a!flatten(local!errors)) ), local!anyErrors: and(not(isnull(local!allErrors)), length(local!allErrors) > 0), { errors: local!allErrors, anyErrors: local!anyErrors } )
Expression 2:
a!localVariables( local!result: rule!SH_ErrorGenerator(), local!errors: local!result.errors, local!anyErrors: and(not(isnull(local!errors)), length(local!errors) > 0), local!anyErrors )
Here is the result I see.
result.anyErrors (calculated by SH_ErrorGenerator) is false (as it should be), but local!anyErrors (calculated by second rule) says true. And even the local variables screen says there are 0 items in the array.
Any idea what's going on here?
Thank you.
Discussion posts and replies are publicly visible
Appian treats lists with empty strings as having length, but they cannot be indexed.Use a!isNullOrEmpty() to check for real errors instead of length().
And yet, within SH_ErrorGenertor length() did return 0. Why does it sometimes return 0 and sometime return 1 for the same value?
You are correct in that isNullOrEmpty does return true in this case.