<?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>How to edit nested objects in Appian Script task in process</title><link>https://community.appian.com/discussions/f/data/37884/how-to-edit-nested-objects-in-appian-script-task-in-process</link><description>Hi, 
 I have a data like 
 
 
 now I have to assign all the ids to null value in a script task in process model. How to do that? I have tried: 
 It not worked for me. How to achieve this?</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: How to edit nested objects in Appian Script task in process</title><link>https://community.appian.com/thread/142475?ContentTypeID=1</link><pubDate>Tue, 05 Nov 2024 07:25:31 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:1d535e1e-511c-4c28-b800-b1dbd961dd98</guid><dc:creator>Stefan Helzle</dc:creator><description>&lt;p&gt;Well, did you try to use &amp;quot;null&amp;quot; as the value?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to edit nested objects in Appian Script task in process</title><link>https://community.appian.com/thread/142471?ContentTypeID=1</link><pubDate>Tue, 05 Nov 2024 03:43:54 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:28b2d777-b6ea-49a5-be07-b1ed470275e9</guid><dc:creator>Shanmathi Ponnusamy</dc:creator><description>&lt;p&gt;&lt;a href="/members/sowvikr8296"&gt;Sowvik Roy&lt;/a&gt;&amp;nbsp; Please try the below code.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;a!localVariables(
  local!testData: {
    &amp;#39;type!{urn:com:appian:types:SS}SS_TEST&amp;#39;(
      testId: 1,
      fieldOne: &amp;quot;testValue1&amp;quot;,
      fieldTwo: &amp;quot;testValue2&amp;quot;,
      accountHolderDetails: &amp;#39;type!{urn:com:appian:types:SS}SS_Account_Holder&amp;#39;(
        id: 4,
        firstName: &amp;quot;John&amp;quot;,
        email: &amp;quot;sample@test.com&amp;quot;
      ),
      creditCardDetails: {
        &amp;#39;type!{urn:com:appian:types:SS}SS_Credit_Card&amp;#39;(
          creditCardId: 20,
          cardHolderId: 1323,
          lastFourDigits: &amp;quot;8962&amp;quot;,
          creditLimit: &amp;quot;100000&amp;quot;
        ),
        &amp;#39;type!{urn:com:appian:types:SS}SS_Credit_Card&amp;#39;(
          creditCardId: 28,
          cardHolderId: 1323,
          lastFourDigits: &amp;quot;8972&amp;quot;,
          creditLimit: &amp;quot;100000&amp;quot;
        )
      }
    ),
    &amp;#39;type!{urn:com:appian:types:SS}SS_TEST&amp;#39;(
      testId: 2,
      fieldOne: &amp;quot;testValue1&amp;quot;,
      fieldTwo: &amp;quot;testValue2&amp;quot;,
      accountHolderDetails: &amp;#39;type!{urn:com:appian:types:SS}SS_Account_Holder&amp;#39;(
        id: 22,
        firstName: &amp;quot;Daniel&amp;quot;,
        email: &amp;quot;sample23@test.com&amp;quot;
      ),
      creditCardDetails: {
        &amp;#39;type!{urn:com:appian:types:SS}SS_Credit_Card&amp;#39;(
          creditCardId: 100,
          cardHolderId: 1800,
          lastFourDigits: &amp;quot;8962&amp;quot;,
          creditLimit: &amp;quot;100000&amp;quot;
        ),
        &amp;#39;type!{urn:com:appian:types:SS}SS_Credit_Card&amp;#39;(
          creditCardId: 200,
          cardHolderId: 1800,
          lastFourDigits: &amp;quot;8972&amp;quot;,
          creditLimit: &amp;quot;100000&amp;quot;
        )
      }
    )
  },
  a!forEach(
    items: local!testData,
    expression: a!localVariables(
      local!accountHolderDetailsUpdated: a!update(
        data: fv!item.accountHolderDetails,
        index: &amp;quot;id&amp;quot;,
        value: null
      ),
      local!creditCardUpdated: a!update(
        data: fv!item.creditCardDetails,
        index: &amp;quot;creditCardId&amp;quot;,
        value: null
      ),
      &amp;#39;type!{urn:com:appian:types:SS}SS_TEST&amp;#39;(
        testId: fv!item.testId,
        fieldOne: fv!item.fieldOne,
        fieldTwo: fv!item.fieldTwo,
        accountHolderDetails: local!accountHolderDetailsUpdated,
        creditCardDetails: local!creditCardUpdated
      )
    )
  )
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to edit nested objects in Appian Script task in process</title><link>https://community.appian.com/thread/142470?ContentTypeID=1</link><pubDate>Tue, 05 Nov 2024 02:26:03 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:8f378309-ebc5-4d07-bd00-53638a213d14</guid><dc:creator>Sowvik Roy</dc:creator><description>&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;a!localVariables(
  local!data: {
    {
      subdata: {id:1},
      subdataitems: {
        {id: 2},
        {id: 3},
      }
    },
    {
      subdata: {id:1},
      subdataitems: {
        {id: 5},
        {id: 6},
      }
    },
  },
)&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Now I want output like this&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;{
    {
      subdata: {id:null},
      subdataitems: {
        {id: null},
        {id: null},
      }
    },
    {
      subdata: {id:null},
      subdataitems: {
        {id: null},
        {id: null},
      }
    },
  }&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Now how do I achieve this?&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to edit nested objects in Appian Script task in process</title><link>https://community.appian.com/thread/142445?ContentTypeID=1</link><pubDate>Mon, 04 Nov 2024 17:35:37 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:b39ec8e4-b076-4255-9406-28b17d37411a</guid><dc:creator>Stefan Helzle</dc:creator><description>[quote userid="261165" url="~/discussions/f/data/37884/how-to-edit-nested-objects-in-appian-script-task-in-process"]It not worked for me[/quote]
&lt;p&gt;??? What output do you observe?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;... a few moments later ... a tiny working example&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;a!localVariables(
  local!data: {
    {
      id: 1,
      items: {
        {id: 2},
        {id: 3},
      }
    },
    {
      id: 4,
      items: {
        {id: 5},
        {id: 6},
      }
    },
  },
  a!forEach(
    items: local!data,
    expression: a!update(
      /* Pass the updated data with a new ID */
      data: a!update(
        data: fv!item,
        index: &amp;quot;id&amp;quot;,
        value: fv!index + 5
      ),
      /* Then the econd update comes here */
      index: &amp;quot;items&amp;quot;,
      value: a!forEach(
        items: fv!item.items,
        expression: a!update(
          data: fv!item,
          index: &amp;quot;id&amp;quot;,
          value: fv!index + 6
        )
      )
    )
  )
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>