<?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>correct syntax saving to a multivalue CDT</title><link>https://community.appian.com/discussions/f/general/13274/correct-syntax-saving-to-a-multivalue-cdt</link><description>I know this is due to not enough coffee, but here goes. 
 I&amp;#39;ve a simple interface A. I have a CDT defined as an Array type. At runtime, the CDT is populated with data. (cdt[1]). 
 On click of a button, i wish to save a new set of values to cdt[2] or 3</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: correct syntax saving to a multivalue CDT</title><link>https://community.appian.com/thread/63101?ContentTypeID=1</link><pubDate>Thu, 29 Nov 2018 17:01:32 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:f49a5ff4-713c-46b0-8bd3-3680ca029348</guid><dc:creator>davel001150</dc:creator><description>Essentially create a new singular value of the CDT type using type constructor and input new values in type constructor, then use either append() function or updateArray() function to stick it onto the end of the array of CDT or update one of the existing values, respectively.&lt;br /&gt;
&lt;br /&gt;
I think other answers have spelled out in detail how to use type constructor.  For a simple enough CDT, I suppose dot notation could work, but it can grow impressively complicated rather swiftly.  Type constructor method remains about equally convoluted regardless of size.&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: correct syntax saving to a multivalue CDT</title><link>https://community.appian.com/thread/63038?ContentTypeID=1</link><pubDate>Tue, 27 Nov 2018 18:39:52 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:c121841b-e42c-4dac-8ced-91451365b5f1</guid><dc:creator>Joubin Izadi</dc:creator><description>&lt;p&gt;Hey Paul,&lt;/p&gt;
&lt;p&gt;If I&amp;#39;m understanding you correctly, you have a rule input that is a CDT array. It begins with one CDT. You want to append a new CDT to this rule input.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;mohamedt808 and&amp;nbsp;sagarl511 both had good solutions - I&amp;#39;ve compiled them into the below code sample to make it clearer what they were suggesting:&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The first button uses dictionary format to add to our CDT array.&lt;/p&gt;
&lt;p&gt;The second button uses casting to add to our CDT array.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;There is one rule input (ri!cdtArray) of Any Type.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I also created a CDT named &amp;quot;emp&amp;quot; with two fields, id (number), and name (text).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;{
  a!forEach(
    items: ri!cdtArray,
    expression: a!textField(
      label: &amp;quot;Item #&amp;quot; &amp;amp; fv!index &amp;amp; &amp;quot;: &amp;quot;,
      value: fv!item,
      readOnly: true
    )
  ),
  a!buttonArrayLayout(
    buttons: {
      a!buttonWidget(
        label: &amp;quot;Add to RI With Dictionary (1, Brian)&amp;quot;,
        saveInto: {
          a!save(
            ri!cdtArray,
            append(
              ri!cdtArray,
              {id: 1, name: &amp;quot;brian&amp;quot;}
            )
          )
        }
      ),
      a!buttonWidget(
        label: &amp;quot;Add to RI With Cast (2, Jenny)&amp;quot;,
        saveInto: {
          a!save(
            ri!cdtArray,
            append(
              ri!cdtArray,
              &amp;#39;type!{urn:com:appian:types}emp&amp;#39;(
                id: 2,
                name: &amp;quot;Jenny&amp;quot;
              )
            )
          )
        }
      )
    }
  )
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Hope that helps!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: correct syntax saving to a multivalue CDT</title><link>https://community.appian.com/thread/63020?ContentTypeID=1</link><pubDate>Tue, 27 Nov 2018 04:23:50 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:e7838396-9a6b-4214-b7d3-9886a7278b58</guid><dc:creator>sainadhn401</dc:creator><description>If you are still looking for a solution.&lt;br /&gt;
I had similar issue the way i used to overcome is as follows. May not be recommended when data set is really huge.&lt;br /&gt;
a!foreach(&lt;br /&gt;
      items: ri!cdt.field,&lt;br /&gt;
      expression: &lt;br /&gt;
    a!save(ri!cdt[fv!index].field,&lt;br /&gt;
    {index(ri!multipleListVariable,fv!index,0)}&lt;br /&gt;
    )&lt;br /&gt;
    )&lt;br /&gt;
PS: the target CDT and multipleListVariable should of same length. Most probably this should be the case.&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: correct syntax saving to a multivalue CDT</title><link>https://community.appian.com/thread/60123?ContentTypeID=1</link><pubDate>Mon, 10 Sep 2018 05:40:25 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:675cbb91-b7e6-4ac3-bff8-691e36849b6a</guid><dc:creator>Dastagiri Dudekula</dc:creator><description>First, create a cdt with the required fields. Second create a rule to map the array values to the cdt using type! constructor. Third call the rule on button click by passing the generated array cdt values. In case of multiple cdts use for each.&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: correct syntax saving to a multivalue CDT</title><link>https://community.appian.com/thread/60122?ContentTypeID=1</link><pubDate>Mon, 10 Sep 2018 04:33:37 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:6fde4c16-11c3-4e65-af7b-0d4423ea518e</guid><dc:creator>sagarl511</dc:creator><description>I suggest to use type!CDT() to create/construct object of data/cdt type on the fly and then use saveinto(cdt[2],type!CDT()), only if the values are in different rule inputs.&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: correct syntax saving to a multivalue CDT</title><link>https://community.appian.com/thread/60099?ContentTypeID=1</link><pubDate>Fri, 07 Sep 2018 16:51:11 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:f97c39d8-fafe-42dc-877d-3c5ee5512444</guid><dc:creator>chandu</dc:creator><description>Hi Paul, Please go through the below SAIL Recipe you will get good Idea &lt;br /&gt;
&lt;a href="https://docs.appian.com/suite/help/18.3/recipe_add_edit_and_remove_data_in_an_inline_editable_grid.html"&gt;docs.appian.com/.../recipe_add_edit_and_remove_data_in_an_inline_editable_grid.html&lt;/a&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: correct syntax saving to a multivalue CDT</title><link>https://community.appian.com/thread/60094?ContentTypeID=1</link><pubDate>Fri, 07 Sep 2018 14:17:39 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:92b709d0-6237-4324-add0-3554a27ebd3d</guid><dc:creator>mudit</dc:creator><description>Thanks For correcting, You are right.&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: correct syntax saving to a multivalue CDT</title><link>https://community.appian.com/thread/60093?ContentTypeID=1</link><pubDate>Fri, 07 Sep 2018 13:53:32 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:9a91779d-cba1-4ee6-bb2a-934e1df22d65</guid><dc:creator>santhosh Kumar</dc:creator><description>Values can be saved only in load() variable, rule input, process variable, or node input as a target  but not functions. Here Index() is a function and so it would throw error if you use it on saveinto or a!save() as a target..&lt;br /&gt;
&lt;br /&gt;
Wrong Usage : a!save(index(ri!test,1,null()), value)&lt;br /&gt;
Correct Usage : a!save(ri!test[1], value)&lt;br /&gt;
&lt;br /&gt;
I am wondering whether you are successfully able to save a value using index() as a target which ideally would throw error.&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: correct syntax saving to a multivalue CDT</title><link>https://community.appian.com/thread/60002?ContentTypeID=1</link><pubDate>Wed, 05 Sep 2018 14:54:01 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:6c362fac-854b-4b55-b26f-09fe9207f727</guid><dc:creator>mudit</dc:creator><description>&lt;p&gt;There is no best practice defined for use of dot&amp;nbsp; in a!save (at least nothing i found) at most places index is recommended when it comes to CDTs .Also&amp;nbsp; When&amp;nbsp; index is recommended for CDTs and array retrieval&amp;nbsp; of data i see no reason why it cant be used to save it. &lt;br /&gt; &lt;br /&gt; This link might help you for clear understanding.&lt;/p&gt;
&lt;p&gt;&lt;br /&gt; &lt;a href="/discussions/f/best-practices/10871/index-or-dot-notation/47704#47704"&gt;community.appian.com/.../47704&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: correct syntax saving to a multivalue CDT</title><link>https://community.appian.com/thread/60001?ContentTypeID=1</link><pubDate>Wed, 05 Sep 2018 14:23:48 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:b5f6ba1e-444d-4303-a620-a8699de7da2c</guid><dc:creator>santhosh Kumar</dc:creator><description>Index function should not be used in save operation as it would throw error. For save operations dot operator should be used as ri!cdt.column&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: correct syntax saving to a multivalue CDT</title><link>https://community.appian.com/thread/60000?ContentTypeID=1</link><pubDate>Wed, 05 Sep 2018 14:14:26 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:e5eb92d8-abbf-478b-9f0c-2a08f1ed3d1b</guid><dc:creator>mohamedt808</dc:creator><description>hi paul, &lt;br /&gt;
&lt;br /&gt;
you should have a value that is initialized. &lt;br /&gt;
&lt;br /&gt;
incase if this interface rule is placed inside a for each you can use index parameter, &lt;br /&gt;
&lt;br /&gt;
i.e:&lt;br /&gt;
&lt;br /&gt;
 value:{id:fv!index} ,&lt;br /&gt;
saveInto:a!save(target , append(target,save!value))&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: correct syntax saving to a multivalue CDT</title><link>https://community.appian.com/thread/59999?ContentTypeID=1</link><pubDate>Wed, 05 Sep 2018 13:53:54 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:3c4eb279-0dbd-4ea6-b050-404f4f43db0b</guid><dc:creator>mudit</dc:creator><description>&lt;p&gt;Use the below code format .. Hope it helps.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;
value:ri!xyz,
saveInto:{
a!save(index(cdt,&amp;quot;column1&amp;quot;,{}),save!value),
a!save(index(cdt2,&amp;quot;column2&amp;quot;,{}),save!value)
/*you can use  many repetetions */
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: correct syntax saving to a multivalue CDT</title><link>https://community.appian.com/thread/59995?ContentTypeID=1</link><pubDate>Wed, 05 Sep 2018 13:29:16 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:f182f462-d16e-4139-b00c-f34dda0c3fbd</guid><dc:creator>bradc</dc:creator><description>&lt;p&gt;Hi Paul,&lt;br /&gt; &lt;br /&gt; I typically do the following:&lt;br /&gt; &lt;br /&gt; a!save(target: ri!CDT, value: append(ri!CDT,type!CDT(field1: &amp;quot;ABC&amp;quot;, field2: &amp;quot;123&amp;quot;)))&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: correct syntax saving to a multivalue CDT</title><link>https://community.appian.com/thread/59993?ContentTypeID=1</link><pubDate>Wed, 05 Sep 2018 12:40:19 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:0f7bf087-9fa1-42de-aa8a-080ce7609550</guid><dc:creator>Rama Thummala</dc:creator><description>Hi &lt;a href="/members/pauls0003"&gt;pauls0003&lt;/a&gt; ,&lt;br /&gt;
&lt;br /&gt;
Suppose, if you want to save field1 of CDT[1]&lt;br /&gt;
&lt;br /&gt;
saveInto:{&lt;br /&gt;
a!save(&lt;br /&gt;
cdt[2].field1,&lt;br /&gt;
cdt[1].field1&lt;br /&gt;
)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Hope it helps..!!&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>