I got this error when none of the interfaces or expression rules mentioned use the load() function, they all use a!localVariables(). Does anyone know why this error could still be appearing?
"Interface Definition: Expression evaluation error ... The load() function cannot be used within rules called by looping functions other than a!forEach(). Pass the necessary variables via rule inputs or use a!forEach()."
Discussion posts and replies are publicly visible
This is a bad error message, but I'm pretty sure the cause of it is usually using the function a!forEach inside of another looping function like reduce(). Any chance you are doing that?
Yes exactly the same I am doing using a!foreach inside reduce fn. At expression rule level it is working fine but as soon as I implement it to main rules it is giving error on UI. So any solution for it to overcome this issue. I tried using a!refreshvariable and refreshalways as true but sill same issue.
Any help would be appreciated
a!forEach unfortunately cannot be used inside of reduce. Instead of a!forEach, you'll have to use fn!apply(),
I just spent a whole day tracking down and coding around this strange bug :-(
It is actually possible to have foreach() in a function (expr. rule) called by a function using reduce(), as long as this topmost function is not called from an interface. My workaround was to move some code (including the call of the topmost function) out of the interface and into a script task.
I strongly suggest that Appian remove this strange limitation - and while they are at it: Introduce tail recursion optimization, so that we (developers) can skip the reduce() in favor of recursive functions: Most of the time reduce() is an acceptable substitute for recursion, but when the number of iterations (recursions) is not known in advance, it is inadequate.
I agree that this bug should be removed. It makes it extremely difficult for the beginners.
BTW, Appian supports recursion.
Can you give more context on your use case - what were you trying to do? There might be other ways to achieve a similar outcome without using fn!reduce().
I'm modernizing the GBL suite and part of that is replacing apply() and similar functions with a!forEach() or other modern function where appropriate. I discovered this issue as well testing in an interface after making my modernization changes. Looks like I will need to do a deeper dive of a rewrite.