RESOLVED: Error on interfaces referencing a Rule using a!localVariables() within an apply() on the Interface

Certified Lead Developer

I am creating this post so that if anyone else runs into the below Error on an Interface, when they try to search for it on Google, they will see this & be able to fix it easily.

Interface Definition: Expression evaluation error in rule 'applylocalvartestexpression': local!dollarConversion uses a refresh configuration that is not supported in looping functions other than a!forEach(). All other looping functions do not support variables that use the default behavior or configurations other than "refreshAlways". Change the variables refresh configurations using a!refreshVariable(), pass the necessary variables via rule inputs, or use a!forEach() instead.

Root Cause: It is generally recommended to replace load()/with() => a!localVariables(), but when this update is made in an Expression Rule and there is an interface (or interface-dependent Expression Rule) referencing it with an apply(), this will break the interface. This is because "a!localVariables does not support partial function evaluation." Unsure if it matters, but our environment is on an Appian Cloud instance.

To Fix: Update the interface or interface-dependent Expression Rule by changing apply() => a!forEach(). In some cases where the apply() is not on the interface, you may need to start with the Rule where the expression evaluation error is & backtrack through the Dependents back to the interface, then check in-between Expression Rules to locate the apply() & update to a!forEach().

For anyone curious about this issue, it is simple to reproduce.

(1) Create/Save an Expression Rule with a Decimal Rule Input & the below code:

a!localVariables(local!dollarConversion: dollar(ri!decimal), local!dollarConversion)

(2) Open an interface to test on & use the below code (I like to duplicate a tab in my environment & update the URL to .../suite/design/interface):

a!sectionLayout(
  label: "Test Interface",
  contents: a!textField(
    label: "Test Field", labelPosition: "JUSTIFIED", readOnly: true,
    value: apply(rule!ApplyLocalVarTestExpression(_), {42.42, 12.34, 77.77})
  )
)

NOTE: This Error only affects Interfaces, not Expression Rules (it actually works as expected).

e.g., in a Test Expression Rule I had the following code: apply(rule!ApplyLocalVarTestExpression(_), {42.42, 12.34, 77.77} )

  Discussion posts and replies are publicly visible