<?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 variable</title><link>https://community.appian.com/discussions/f/general/20244/local-variable</link><description>hi, 
 I have a local variable &amp;quot;array of object&amp;quot; , 
 I need to update value &amp;quot;seenBy&amp;quot; for one field in all array objects, 
 
 but the issue is :- 
 &amp;quot;An error occurred while trying to write to the data store [chatDS]. No values have been written. Details</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: local variable</title><link>https://community.appian.com/thread/79050?ContentTypeID=1</link><pubDate>Thu, 21 Jan 2021 03:28:18 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:e2ea5f1c-d235-4277-9b29-a20a493fa275</guid><dc:creator>Selvakumar Kumarasamy</dc:creator><description>&lt;p&gt;&amp;nbsp;That&amp;#39;s a good solution. But the only problem&amp;nbsp;which accompanies this solution is&amp;nbsp;a change in the CDT structure in the future.&lt;/p&gt;
&lt;p&gt;Let&amp;#39;s say at first we have 10 fields in the CDT and we use this&amp;nbsp;type! constructor solution in 5 places. After 6 months, we add 2 more fields to the CDT due to business requirements. Now again, we need to revisit all the above 5 places to add those two fields in our logic. Hence futuristic code change is a considerable factor for this solution.&lt;/p&gt;
&lt;p&gt;Whereas the update dictionary function performs multiple field value updates and it does not have any impact based on CDT change.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: local variable</title><link>https://community.appian.com/thread/79040?ContentTypeID=1</link><pubDate>Wed, 20 Jan 2021 19:19:06 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:29eadd7f-27f9-4ca9-99e4-e3548ab8797d</guid><dc:creator>davel001150</dc:creator><description>&lt;p&gt;There&amp;#39;s a fairly tedious solution, which makes a good bit of code, but it&amp;#39;s reliable and works with Appian right out of the box.&amp;nbsp; You use type! constructor in a forEach.&lt;/p&gt;
&lt;p&gt;a!forEach(&lt;/p&gt;
&lt;p&gt;items: yourArray,&lt;/p&gt;
&lt;p&gt;expression: type!&amp;lt;yourCDTsName&amp;gt;(&lt;/p&gt;
&lt;p&gt;field1: fv!item.field1,&lt;/p&gt;
&lt;p&gt;field2: fv!item.field2,&lt;/p&gt;
&lt;p&gt;field3: fv!item.field3,&lt;/p&gt;
&lt;p&gt;/*The only thing you actually wanted to change*/&lt;/p&gt;
&lt;p&gt;field4: ri!newValue,&lt;/p&gt;
&lt;p&gt;field5: fv!item.field5,&lt;/p&gt;
&lt;p&gt;and so on.....&lt;/p&gt;
&lt;p&gt;)&lt;/p&gt;
&lt;p&gt;We all actually have the same idea about the forEach.&amp;nbsp; The reason yours isn&amp;#39;t working is because you&amp;#39;re attempting to use the save! function.&amp;nbsp; That only works in an interface component&amp;#39;s saveInto block.&amp;nbsp; It&amp;#39;s designed to not work unless a user has actively clicked on a thing.&amp;nbsp; It won&amp;#39;t work outside a saveInto by design.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The plugin works, if you want to deal with the plugin, but this version also works too.&amp;nbsp; You build a NEW CTD exactly like the old one in every detail, except for the one detail you want changed.&amp;nbsp; This method also allows you to alter multiple details as you see fit simultaneously.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: local variable</title><link>https://community.appian.com/thread/79000?ContentTypeID=1</link><pubDate>Tue, 19 Jan 2021 08:23:12 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:8aaf01e4-12bf-4352-9b92-4ef9a08212dc</guid><dc:creator>Ahmad yaqoup</dc:creator><description>&lt;p&gt;thanks&amp;nbsp;&lt;a class="internal-link view-user-profile" href="/members/selvakumark"&gt;Selvakumar_Kumarasamy&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: local variable</title><link>https://community.appian.com/thread/78982?ContentTypeID=1</link><pubDate>Mon, 18 Jan 2021 14:21:06 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:ce3a7880-39a2-41b0-8ce3-56ff3c76dd37</guid><dc:creator>Selvakumar Kumarasamy</dc:creator><description>&lt;p&gt;Hi Ahmad,&lt;/p&gt;
&lt;p&gt;For updating a particular field in a dictionary object, the function&amp;nbsp;&lt;span&gt;&lt;strong&gt;updateDictionary()&lt;/strong&gt; from the &amp;quot;&lt;a href="/b/appmarket/posts/cdt-manipulation" rel="noopener noreferrer" target="_blank"&gt;Dictionary Manipulation&lt;/a&gt;&amp;quot; custom plug-in would be more helpful. An example code is attached.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;a!localVariables(
  local!msg: {
    { id: 1, isDeleted: false(), seenBy: &amp;quot;You&amp;quot; },
    { id: 2, isDeleted: false(), seenBy: null }
  },
  a!forEach(
    items: local!msg,
    expression: updatedictionary(
      dictionary: fv!item,
      fieldsAndValues: if(
        isnull(fv!item.seenBy),
        { seenBy: &amp;quot;Me&amp;quot; },
        { seenBy: concat(fv!item.seenBy, &amp;quot;,&amp;quot;, &amp;quot;Me&amp;quot;) }
      )
    )
  )
)&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Hope this helps you.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>