So, I am trying to capture and store nested data from USDA Database - API (image below)
Now I am trying to store this data in a record - fields being gtinUpc, number, name, amount, and unitName. I am trying to use the forEach-nested loop example from
https://docs.appian.com/suite/help/23.1/fnc_looping_a_foreach.html.
However, when I try to nest another forEach and iterate over the foodNutrients, I get errors. I have tried moving lines around - for example, move line 21 to outside the inner a!localVariables - nothing seems to work.
As always, any and all feedback/assistance would be appreciated.
Thanks
Discussion posts and replies are publicly visible
Hey MaNa, do you have an Appian Mentor near by. I think a face to face session with a more experienced designer might help to resolve some misunderstandings :) and i can always recommend to do your first steps with the appian academy.
MaNa said:That variable is declared on line 30 - and is being given a value on line 42
To reiterate and simplify upon the prior correct responses by Stefan and Richard: this is not how local variables work. You need to set the value of the local variable where you declare it. Any use of a local variable needs to be done inside the same a!localVariables() statement in which it was declared. The code snippets you've posted here all violate both of these tenets.
Mike, Stefan, Nasirs, and others:
Thank you for all the responses & feedback - very much appreciate it!
I think I have a better understanding of a!localVariables. Going work on how to connect recordType to web integration using the Space X tutorial.
Ma
I am not aware of any Appian Mentors nearby.
Use nesting of localvariables() like following.
a!localVariables( local!level1, a!localVariables( local!level2: local!level1, a!forEach( items: local!level2, expression: a!localVariables( local!level3: fv!item, { "Do the processing here" } ) ) ) )
Abhay,
Thanks - going forward, I will keep this in mind.