Trying to understand local/scoping of variables

Hi:

I was experimenting with the Grid example in Appian Tutorials (https://docs.appian.com/suite/help/23.1/Grid_Tutorial.html) and noticed that I had some rows with no firstName and LastName.  So, I thought I would use "fv!row.firstName" as part of the showWhen-attribute to prevent those rows from being show (see image below).  However, I am getting "scoping error" messages.  I know I can use query to filter out those rows but thought I would experiment with this approach because I have had issues with understanding local-variable scoping.  For example, when I use {} right after a!localVariables (), I get scoping error (see second image. 

Any responses to helping me understand local-variables/scoping would be appreciated.

Thank you.

Ma

  Discussion posts and replies are publicly visible

Parents Reply
  • Abhay:

    Thanks for helping me understand this concept.  As for the syntax in image 2, isn't the a!localVariable() on line 1, similar to the example in your response?

    Isn't the scope defined by a!localVariable valid for all statements between matching pairs of ()?  So anything you defined after line 1 should be available throughout the rest of the code.  Am I wrong in that interpretation ?

    I was using this as the reference (https://docs.appian.com/suite/help/23.1/Local_Variables.html).  In the example they have:

    value: if(isnull(local!input), "No", "Yes"),

    While I understand I am using "fv!row" not "local!input" as part of showWhen attribute (showWhen:a!isNotNullOrEmpty(fv!row.number)) , it gives me an error (image 1 in original post).  I am trying to understand why/when I can use "fv!row" and why there is a scoping error.

    a!columnsLayout(
      columns: {
        a!localVariables(
          local!input,
          {
            a!columnLayout(
              contents: {
                a!textField(
                  label: "Input",
                  value: local!input,
                  saveInto: local!input
                )
              }
            ),
            a!columnLayout(
              contents: {
                a!textField(
                  label: "Input Entered?",
                  value: if(isnull(local!input), "No", "Yes"),
                  readOnly: true
                )
              }
            )
          }
        )
      }
    )
    

Children