Have you ever wondered how Appian manages data behind the scenes? Understanding variable scoping can unlock powerful capabilities in your applications.
Code evaluation in Appian is all about scope. That scope contains all the variables our code can use. And, scopes can be nested. Code, running inside the inner scope, can also access variables from the outer scope. But not the other way around.

Appian populates this scope with all sorts of variables, and we can do so ourselves.
Let’s see what we can do to populate a scope.
- Rule Inputs: Define the outer scope of code execution and communicate with the outside world.
- Local Variables: Add inner scope to reuse computed values or manage the inner state of your component. Local variable scope can be nested. A common example is to use local variables in a nested a!foreach() to store the outer item.
Now, Appian also has a method to define scope. When using certain functions, Appian creates special variables inside the scope of the function call. They are accessible via the fv! domain, which stands for “function value”.
Again, a good example is the a!foreach() function. There is a whole bunch of special variables available inside the expression parameter.
- fv!item: The current array item
- fv!index: The current item’s index in the array
- fv!itemCount: The number of items
- fv!identifier: When using a DataSubset, the current item’s identifier
- fv!isFirst: True during the first iteration, false afterward
- fv!isLast: True during the last iteration, false beforehand
But wait! This article is about saveInto! What does this have to do with scoping?
SaveInto
Well, when evaluating a saveinto, Appian adds the value to be saved into this scope. Very often, this is not directly visible because we just store a user entered value into a variable. But when using the a!save() function to add more complex logic, this scope becomes more prominent.
The a!save() function introduces a special variable, save!value, which stores the value to be saved. And we can use this function to modify that variable and create a new scope.
Just recently I was toying around with the Open Street Map plugin. When clicking inside the map, it can return a JSON structure holding the coordinates and address information. I decided to build a small interface component to simplify using this plugin. So I wanted to directly parse the JSON into a normal Appian dictionary for easier accessibility.

That rule input is of type “List of Save”. I use it to be able to add saveInto logic from the outside. But before calling this logic, I turn the plain JSON string into an Appian dictionary.
Inside my component, the save!value is this JSON string
"{""latlng"":{""lat"":45.46043080204,""lng"":9.140681267689},""address"":{""Match_addr"":""Viale Caterina da Forl" & fn!char(236) & " 43-43, 20146, Milano"",""LongLabel"":""Viale Caterina da Forl" & fn!char(236) & " 43-43, 20146, Milano, ITA"",""ShortLabel"":""Viale Caterina da Forl" & fn!char(236) & " 43-43"",""Addr_type"":""StreetAddress"",""Type"":"""",""PlaceName"":"""",""AddNum"":""43"",""Address"":""Viale Caterina da Forl" & fn!char(236) & " 43"",""Block"":"""",""Sector"":"""",""Neighborhood"":""Bande Nere"",""District"":"""",""City"":""Milano"",""MetroArea"":"""",""Subregion"":""Milano"",""Region"":""Lombardia"",""RegionAbbr"":"""",""Territory"":"""",""Postal"":""20146"",""PostalExt"":"""",""CntryName"":""Italia"",""CountryCode"":""ITA"",""X"":9.140681267689,""Y"":45.46043080204,""InputX"":9.140625,""InputY"":45.460130637921}}"
For any save operation provided from the outside, like in this small test

that data is a nice Appian dictionary ready for consumption.

Now, my colleagues do not always have to separately validate and parse that JSON string.
What a neat feature this is! And yes, you can do much more here. Resolve an identifier into its full record using a!queryRecordType? Sure! An API call? Yes! In combination? Oh yes! You can even use a!localVariables() to do even more crazy things!
Summary
The magic of saveInto … I hope I did not promise too much. Do your own research and make sure to understand variable scoping in Appian, in which situations scopes are important and how to modify them.
Rock your scopes, and your save operations!
