<?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>local variables</title><link>https://community.appian.com/discussions/f/user-interface/29948/local-variables</link><description>hi i am trying to save the value of &amp;quot;Account Balance&amp;quot; to calculate the dollar equivalent field. 
 i wrote the code below and tried to save the value of &amp;quot; dollar equivalent &amp;quot; in a local variable but the value stays NULL, i also tried to replace with rule</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: local variables</title><link>https://community.appian.com/thread/118915?ContentTypeID=1</link><pubDate>Sun, 10 Sep 2023 12:27:27 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:ca8413ae-8b01-4102-a869-ea1e3efddba0</guid><dc:creator>Mathieu Drouin</dc:creator><description>&lt;p&gt;Depends on what you want to do. If you are actually typing a value in the Account Balance field, this is what it would look like:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;a!localVariables(
  local!currencyType: 1,
  local!record: a!map(
    USD: 0,
    USDBALANCE: 0,
    dollar: 0,
  ),
  local!usd: local!record.USD,
  local!usdBalance: local!record.USDBALANCE,
  local!dollar: local!record.dollar,
  {
    a!floatingPointField(
      label: &amp;quot;Account Balance&amp;quot;,
      value: local!usdBalance,
      saveInto: {
        local!usdBalance,
        a!save(
          local!dollar,
          a!match(
            value: local!currencyType,
            equals: 1,
            then: {
              if(
                a!isNotNullOrEmpty(local!usdBalance),
                (local!usdBalance / 3.5),
                - 1
              )
            },
            equals: 2,
            then: { local!usdBalance },
            equals: null,
            then: { false() },
            default: then: { false() }
          )
        ),
        a!save(local!usd, local!dollar)
      }
    ),
    a!floatingPointField(
      label: &amp;quot;Dollar Equivalent&amp;quot;,
      labelPosition: &amp;quot;ABOVE&amp;quot;,
      value: local!dollar,
      saveInto: local!dollar
    )
  }
)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;If you want to handle the case where you pre-populate these values and just save them back without you typing anything. It would be best to calculate them before sending them as rule inputs. Otherwise, you&amp;nbsp;could also initialize them as local variables but you have to be sure to save them back into your rule input when you submit the form.&lt;/p&gt;
&lt;p&gt;A couple of extra links that might help:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://docs.appian.com/suite/help/23.3/recipe-set-the-default-value-of-cdt-fields-based-on-a-user-input.html"&gt;docs.appian.com/.../recipe-set-the-default-value-of-cdt-fields-based-on-a-user-input.html&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.appian.com/suite/help/23.3/recipe-set-the-default-value-of-an-input-on-a-start-form.html"&gt;docs.appian.com/.../recipe-set-the-default-value-of-an-input-on-a-start-form.html&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: local variables</title><link>https://community.appian.com/thread/118912?ContentTypeID=1</link><pubDate>Sun, 10 Sep 2023 09:38:40 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:baa1c826-6666-4e4b-8fdd-0fca27718458</guid><dc:creator>Stefan Helzle</dc:creator><description>&lt;p&gt;That is because you fell into a typical trap like many others new to Appian. Input fields do only display a value, and the saveInto is only ever evaluated when the user types a different value. This means, that you need to make any calculations in the saveInto using one or more a!save().&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>