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
  • 0
    Certified Lead Developer
    in reply to MaNa

    Yes, if the requirement is that your form should show GPA and that the only rows which appear are those where it's non-blank, then the key is to filter your data in advance of feeding it into your grid.

    If you're querying the data from the DB, then you would simply provide a query filter and filter out rows where that value is not populated.

    If, on the other hand, you are passing the whole data set (with a mixture of rows) like as a process PV array, then you could instead create an on-form temp variable consisting only of the rows you'd like to display.  Something along the lines of, local!myTempArray: a!forEach(ri!myWholeArray, if(a!isNullOrEmpty(fv!item.GPA), {}, fv!item) within your local variables declaration.  Then you'd simply pass that local variable into the data parameter of your grid, and you'd be displaying only the rows which have a value populated here.

Children