<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.appian.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Assignment to local variables in Expression rule</title><link>https://community.appian.com/discussions/f/new-to-appian/29200/assignment-to-local-variables-in-expression-rule</link><description>Hi, 
 I&amp;#39;m trying to save an array value to a local variable, it looks like getting saved, but when I check for the length of the local variable, I&amp;#39;m getting as 0. Where as when I save the same array during declaration of the local variable, I&amp;#39;m getting</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Assignment to local variables in Expression rule</title><link>https://community.appian.com/thread/115526?ContentTypeID=1</link><pubDate>Tue, 04 Jul 2023 07:39:44 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:b3cef757-6c34-45e9-bbf5-1ab40a5943f5</guid><dc:creator>Vasudeva</dc:creator><description>&lt;p&gt;thank you will go through it... really this is a wonderful community &lt;span class="emoticon" data-url="https://community.appian.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Assignment to local variables in Expression rule</title><link>https://community.appian.com/thread/115502?ContentTypeID=1</link><pubDate>Mon, 03 Jul 2023 23:52:51 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:499a2dbd-0e3c-4b77-bcb8-b7819002a4c5</guid><dc:creator>Mathieu Drouin</dc:creator><description>&lt;p&gt;The local variables section pretty much covers it.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://docs.appian.com/suite/help/22.1/Local_Variables.html"&gt;docs.appian.com/.../Local_Variables.html&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Assignment to local variables in Expression rule</title><link>https://community.appian.com/thread/115501?ContentTypeID=1</link><pubDate>Mon, 03 Jul 2023 21:50:46 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:3cdefc56-f13d-4780-ada4-d76a7c62f7d1</guid><dc:creator>Vasudeva</dc:creator><description>&lt;p&gt;Where can I find more info on this, I have tried the expression section of the Appian documentation, but I couldn&amp;#39;t find any thing, I&amp;#39;m looking for examples and howtos..&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I have referred to this -&amp;gt; &lt;a href="https://docs.appian.com/suite/help/22.1/Expressions.html#variables"&gt;docs.appian.com/.../Expressions.html&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Assignment to local variables in Expression rule</title><link>https://community.appian.com/thread/115500?ContentTypeID=1</link><pubDate>Mon, 03 Jul 2023 20:56:03 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:d056da94-b50e-4528-a151-2e9ca8c68470</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;basically, yes.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Assignment to local variables in Expression rule</title><link>https://community.appian.com/thread/115499?ContentTypeID=1</link><pubDate>Mon, 03 Jul 2023 20:55:22 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:69c55d13-46f7-486b-a543-05d135a00a2e</guid><dc:creator>Vasudeva</dc:creator><description>&lt;p&gt;ok, so the rule of thumb is to initialize the local variable during declaration it self. Got it, thanks &lt;span class="emoticon" data-url="https://community.appian.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Assignment to local variables in Expression rule</title><link>https://community.appian.com/thread/115497?ContentTypeID=1</link><pubDate>Mon, 03 Jul 2023 20:48:31 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:ab016469-26ee-4f84-9a47-f7bcdc18aa3d</guid><dc:creator>Mike Schmitt</dc:creator><description>[quote userid="120503" url="~/discussions/f/new-to-appian/29200/assignment-to-local-variables-in-expression-rule/115496#115496"]the value would come after initialization as a result of some equation [/quote]
&lt;p&gt;You would declare its value after any other calculations (usually declared as their own local variables) on which it depends.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Assignment to local variables in Expression rule</title><link>https://community.appian.com/thread/115496?ContentTypeID=1</link><pubDate>Mon, 03 Jul 2023 20:47:01 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:4843a8a4-7c0e-4cd0-b40d-07033532e424</guid><dc:creator>Vasudeva</dc:creator><description>&lt;p&gt;Thanks Mike for your input.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&amp;nbsp; If you know its initial value, then you will assign it at creation time. --&amp;nbsp;&amp;nbsp;&lt;/strong&gt;what if I don&amp;#39;t know the value of the variable during initialization and the value would come after initialization as a result of some equation like we do in traditional programming. how to handle such scenarios.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Assignment to local variables in Expression rule</title><link>https://community.appian.com/thread/115495?ContentTypeID=1</link><pubDate>Mon, 03 Jul 2023 20:45:39 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:2b61de63-12d4-4a9a-b606-acd0601a2d3c</guid><dc:creator>Mathieu Drouin</dc:creator><description>&lt;p&gt;I think maybe having that variable being the key in the dictionary might be doing weird things.&lt;/p&gt;
&lt;p&gt;Try this:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;a!localVariables(
  local!parts: {
    a!map(
      partName: &amp;quot;part1&amp;quot;,
      quantity: 1,
      unitCost: 1
    ),
    a!map(
      partName: &amp;quot;part2&amp;quot;,
      quantity: 1,
      unitCost: 1
    )

  },
  {
    parts: local!parts,
    length: length(local!parts)
  }
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Assignment to local variables in Expression rule</title><link>https://community.appian.com/thread/115494?ContentTypeID=1</link><pubDate>Mon, 03 Jul 2023 20:41:21 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:8bb63384-f185-4811-ab65-0064b7dc58ce</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;There are mainly only 2 places where you can &amp;quot;assign a value&amp;quot; to a local variable:&lt;/p&gt;
&lt;p&gt;1) at declaration&lt;/p&gt;
&lt;p&gt;2) as the result of a user interaction in an interface component&lt;/p&gt;
&lt;p&gt;Seeing as this is an expression rule, and therefore #2 is irrelevant, you will need to assign the value at declaration (#1).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&lt;span style="text-decoration:underline;"&gt;This is the most important concept here&lt;/span&gt;&lt;/em&gt;: There is &lt;em&gt;no such thing&lt;/em&gt;, in Appian&amp;#39;s expression language, as &amp;quot;define a blank local variable then in a later line of code give it a new value&amp;quot;.&amp;nbsp; If you know its initial value, then you will assign it at creation time.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>