<?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>Error Indexing Map in MNI Script Process Node</title><link>https://community.appian.com/discussions/f/new-to-appian/39096/error-indexing-map-in-mni-script-process-node</link><description>I have a process where I have two script nodes. The First creates a parent record type and stores it to a PV!: 
 
 
 
 Next I have and MNI Process Script which builds related records and appends them to the related record list of the record above: 
 </description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Error Indexing Map in MNI Script Process Node</title><link>https://community.appian.com/thread/148076?ContentTypeID=1</link><pubDate>Tue, 13 May 2025 14:04:36 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:f6f5f117-d215-430f-9756-f5377d1dc462</guid><dc:creator>jonathanf_kr</dc:creator><description>&lt;p&gt;Alberto, this change fixed my issue right away.&amp;nbsp; Thanks.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Error Indexing Map in MNI Script Process Node</title><link>https://community.appian.com/thread/148075?ContentTypeID=1</link><pubDate>Tue, 13 May 2025 13:53:26 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:8cd5d8c4-98a0-4579-9a96-1afe15d8a5ef</guid><dc:creator>jonathanf_kr</dc:creator><description>&lt;p&gt;Thanks for all the tips and areas to look for.&amp;nbsp; I&amp;#39;m currently working on a POC / Demo project just learning the ins and outs for our future projects.&amp;nbsp; I specifically was trying out the MNI approach.&amp;nbsp; I&amp;#39;m going to continueto work on that approach for my understanding even though I fully agree the foreach method separated into it&amp;#39;s own rule would be the most scalable / maintainable approach in the future for this specific situation.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Error Indexing Map in MNI Script Process Node</title><link>https://community.appian.com/thread/148063?ContentTypeID=1</link><pubDate>Tue, 13 May 2025 08:43:31 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:87b72557-76d3-428d-83f7-cb82a2a82daa</guid><dc:creator>Alberto Cort&amp;#233;s</dc:creator><description>&lt;p data-start="149" data-end="158"&gt;Hi,&lt;/p&gt;
&lt;p data-start="160" data-end="376"&gt;From what I can tell, the issue is related to using &lt;strong data-start="212" data-end="233"&gt;&amp;quot;is appended to list&amp;quot;&lt;/strong&gt; in the output of a node that is configured as a Multiple Node Instance (MNI) with the &lt;strong data-start="320" data-end="360"&gt;&amp;quot;Run all instances at the same time&amp;quot;&lt;/strong&gt; option enabled.&lt;/p&gt;
&lt;p data-start="378" data-end="764"&gt;When this setting is used, all node instances execute &lt;strong data-start="432" data-end="447"&gt;in parallel&lt;/strong&gt;, and if they all try to append to the same process variable simultaneously, you can run into &lt;strong data-start="541" data-end="560"&gt;race conditions&lt;/strong&gt;.&amp;nbsp;&lt;/p&gt;
&lt;h3 data-start="766" data-end="784"&gt;Suggested fix:&lt;/h3&gt;
&lt;p data-start="785" data-end="988"&gt;Instead of &amp;quot;&lt;strong data-start="212" data-end="233"&gt;is appended to list&lt;/strong&gt;&amp;quot;, switch to &lt;strong data-start="825" data-end="846"&gt;&amp;quot;is stored at index&amp;quot;&lt;/strong&gt; and store each result at &lt;code data-start="872" data-end="890"&gt;tp!instanceIndex&lt;/code&gt;. This ensures each instance writes to a specific index in the array, avoiding concurrency issues.&lt;/p&gt;
&lt;h3 data-start="1039" data-end="1064"&gt;Recommended approach:&lt;/h3&gt;
&lt;p data-start="1065" data-end="1326"&gt;As Mathie and Harsa mentioned, it&amp;rsquo;s usually better to &lt;strong data-start="1119" data-end="1132"&gt;avoid MNI&lt;/strong&gt; altogether for these scenarios. Using &lt;code data-start="1171" data-end="1184"&gt;a!forEach()&lt;/code&gt; in a script task or expression rule is &lt;strong data-start="1224" data-end="1260"&gt;much safer and more maintainable&lt;/strong&gt;, since it runs sequentially and avoids shared variable conflicts.&lt;/p&gt;
&lt;p data-start="1328" data-end="1344"&gt;Hope this helps!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Error Indexing Map in MNI Script Process Node</title><link>https://community.appian.com/thread/148051?ContentTypeID=1</link><pubDate>Tue, 13 May 2025 06:55:06 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:0fc8896d-c23b-4e0a-8d3f-2b9e3feea1de</guid><dc:creator>Harsha Sharma</dc:creator><description>&lt;p&gt;To better debug this and for future scalability as well I would suggest you create an expression rule&amp;nbsp;for the script tasks expression.&lt;/p&gt;
&lt;p&gt;You can pass pv!event, pv!eventIId etc all the process variables, configure the code using a!foreach() and test that your expression rule works as expected with null handlings, date formats etc so that it returns expected output always.&amp;nbsp;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Error Indexing Map in MNI Script Process Node</title><link>https://community.appian.com/thread/148050?ContentTypeID=1</link><pubDate>Tue, 13 May 2025 06:47:12 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:bce3e971-7f98-42cb-8fcb-e758431752e0</guid><dc:creator>David Jimenez </dc:creator><description>&lt;p&gt;Seems that some of the instances is receiving a null.... check it...&amp;nbsp;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Error Indexing Map in MNI Script Process Node</title><link>https://community.appian.com/thread/148039?ContentTypeID=1</link><pubDate>Tue, 13 May 2025 00:28:12 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:7902f4de-954c-428e-9257-1bd3a68bfbbb</guid><dc:creator>Mathieu Drouin</dc:creator><description>&lt;p&gt;Why do you need to do this via MNI in a script task instead of a forEach in an expression rule?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>