Skip to main content
October 31, 2022
Solved

Unexpected "Improperly scoped variable" in an a!match() function

  • October 31, 2022
  • 6 replies
  • 0 views

Hi!

I'm using an a!match function in an interface. I have set the 'value:' parameter of the match function to the output of an expression which outputs a list of CDTs. Subsequently, I'm using this value parameter as 'fv!value' in other parameters. However, I'm receiving the 'improperly scoped variable' warning on multiple occasions when using fv!value (not in all cases). This warning is resolved when calling the same function that is called in the 'value:' parameter over and over again. However, I would prefer to refrain from doing this because of the performance implications of calling the same function multiple times.

A code snippet is attached which shows the following: the times when fv!value is called in the 'whenTrue:' parameter (lines 6 & 14), no warning is given. When fv!value is called in the 'then:' parameter (lines 10, 20 & 23), however, a warning is issued. This does not rhyme with the expected behaviour as described in the documentation. I was hoping someone could shed a light on this!

Thank you for reading.

a!match(
    value: rule!ACE_ReturnACDT(
        input: ri!input
    ),
    whenTrue: contains(
      fv!value.type,
      cons!ACE_ANSWER_TYPE_OPEN
    ),
    then: a!localVariables(
      local!warning1: fv!value,
      /* code redacted for readability */
      ),
    whenTrue: contains(
      fv!value.type,
      cons!ACE_ANSWER_TYPE_MULTIPLE_CHOICE
    ),
    then: if(
      length(fv!value) <= cons!ACE_RADIOBUTTON_DROPDOWN_DIVISION_VALUE,
      rule!ACE_SC_RadioButtonField(
        warning2: fv!value,
      ),
      rule!ACE_SC_DropdownField(
        warning3: fv!value,
    )
    ),
    default: null
)

Best answer by mikes0011

I can reproduce this.  It appears to be a bug.

a!match(
  value: 2,
  
  equals: 2,
  then: a!textField(
    value: fv!value
  ),
  
  default: a!textField(value: "def")
)

Can you open a support case with Appian?  You could drop them a link to this thread as well, at least as a starting point.

FWIW in the future it'd be helpful to post an interface snippet (like the one i have here) that someone could simply copy/paste into a blank interface designer window, i.e. one that doesn't need environment-specific constants, rules etc, along with a screenshot of what they're expecting to see - i wasn't sure what i was looking for at first (though luckily i didn't have to go far before I saw what you mean, in this case).

6 replies

mikes0011
mikes0011Answer
Brainy
October 31, 2022

I can reproduce this.  It appears to be a bug.

a!match(
  value: 2,
  
  equals: 2,
  then: a!textField(
    value: fv!value
  ),
  
  default: a!textField(value: "def")
)

Can you open a support case with Appian?  You could drop them a link to this thread as well, at least as a starting point.

FWIW in the future it'd be helpful to post an interface snippet (like the one i have here) that someone could simply copy/paste into a blank interface designer window, i.e. one that doesn't need environment-specific constants, rules etc, along with a screenshot of what they're expecting to see - i wasn't sure what i was looking for at first (though luckily i didn't have to go far before I saw what you mean, in this case).

The Expression Guru
hansv8637Author
November 1, 2022

Mike, thank you for your response!

I will indeed open a support case and see if Appian can help with this.

Also, thank you for your advice on the interface snippet, yours works too and is easier to copy.

zach.puderbach
Employee
November 2, 2022

Hi all! Thank you for reporting this issue. Appian is tracking this behavior in AN-204631. If your organization has any questions or concerns please open a support ticket to discuss. 

November 15, 2022

This issue has been resolved in 22.4; it is specified in the release notes.

docs.appian.com/.../Appian_Release_Notes.html

mikes0011
Brainy
November 15, 2022

yep i'd noticed that too - i was too distracted to come back here and post it though, so thanks!

The Expression Guru