I have a process where I have two script nodes. The First creates a parent record type and stores it to a PV!:
'recordType!{f68fc74f-edcf-4bec-b576-6aa21d7ae8df}WPA1 Workflow Instance'( 'recordType!{f68fc74f-edcf-4bec-b576-6aa21d7ae8df}WPA1 Workflow Instance.fields.{707eb7ae-ea9f-446e-9f88-d818ff7227fb}parentType': typename(typeof(pv!event)), 'recordType!{f68fc74f-edcf-4bec-b576-6aa21d7ae8df}WPA1 Workflow Instance.fields.{74c50dc1-dd17-43f3-92b6-98bf5753125a}parentId': pv!eventId, 'recordType!{f68fc74f-edcf-4bec-b576-6aa21d7ae8df}WPA1 Workflow Instance.fields.{c939f3ac-6a45-4ca5-9441-44aa056523ca}targetCompletionDate': pv!event['recordType!{f07fa26e-a28d-44ca-ab58-7ba4db20200b}WPA1 Event.fields.{987c7817-ad5b-4c64-b91e-0ab1087a91ea}endDate'], 'recordType!{f68fc74f-edcf-4bec-b576-6aa21d7ae8df}WPA1 Workflow Instance.fields.{d18891c0-c267-4d9a-8370-4bb662b7be83}createdBy': loggedInUser(), 'recordType!{f68fc74f-edcf-4bec-b576-6aa21d7ae8df}WPA1 Workflow Instance.fields.{d2bbcf03-34b1-431a-8ca5-8228506a444a}createdOn': now(), 'recordType!{f68fc74f-edcf-4bec-b576-6aa21d7ae8df}WPA1 Workflow Instance.fields.{bd6e3937-0113-48bd-b62f-22e2f1b3b12f}modifiedBy': loggedInUser(), 'recordType!{f68fc74f-edcf-4bec-b576-6aa21d7ae8df}WPA1 Workflow Instance.fields.{11f44723-e150-4e68-ba0a-1a06096682ea}modifiedOn': now(), 'recordType!{f68fc74f-edcf-4bec-b576-6aa21d7ae8df}WPA1 Workflow Instance.fields.{bd5f02c8-e3b6-41e7-aa0a-57469ad481e9}isActive': "false", 'recordType!{f68fc74f-edcf-4bec-b576-6aa21d7ae8df}WPA1 Workflow Instance.fields.{93b08b29-87c8-4a1f-a46f-7245e8f03587}statusId': 1, 'recordType!{f68fc74f-edcf-4bec-b576-6aa21d7ae8df}WPA1 Workflow Instance.fields.{506fae0f-ba80-4b84-b95b-6bf96a442528}workflowTemplateId': pv!workflowTemplate['recordType!{bb035f50-d14a-4303-9c20-48d3e48deab0}WPA1 Workflow Template.fields.{900e52c7-75ad-4e6c-85ef-6359c8362fc8}id'] )
Next I have and MNI Process Script which builds related records and appends them to the related record list of the record above:
'recordType!{95d43233-0ac2-44c2-a213-4217c2782a30}WPA1 Task Instance'( 'recordType!{95d43233-0ac2-44c2-a213-4217c2782a30}WPA1 Task Instance.relationships.{d25c8435-93f4-4b34-abad-05cbcba1af32}workflowInstance': pv!workflowInstance, 'recordType!{95d43233-0ac2-44c2-a213-4217c2782a30}WPA1 Task Instance.fields.{3386d000-5e7d-44fe-8d2a-ed6a4894e167}taskTemplateId': ac!templateTask['recordType!{26443545-ab3d-444f-9cd1-fbb7ce8d789a}WPA1 Task Template.fields.{59029bb2-8b0f-458e-88cb-14f4d2d18946}id'], 'recordType!{95d43233-0ac2-44c2-a213-4217c2782a30}WPA1 Task Instance.fields.{adf3c23e-9ba1-4445-ae28-8936f5c44f43}startDate': a!subtractDateTime( startDateTime: pv!event['recordType!{f07fa26e-a28d-44ca-ab58-7ba4db20200b}WPA1 Event.fields.{987c7817-ad5b-4c64-b91e-0ab1087a91ea}endDate'], days: ( 7 * ac!templateTask['recordType!{26443545-ab3d-444f-9cd1-fbb7ce8d789a}WPA1 Task Template.fields.{d5a9a527-bbff-429d-9849-e10b960214e4}assignedWeek'] + ac!templateTask['recordType!{26443545-ab3d-444f-9cd1-fbb7ce8d789a}WPA1 Task Template.fields.{784ab85a-387c-4967-b018-dd9adddacab2}durationDays'] ) ), 'recordType!{95d43233-0ac2-44c2-a213-4217c2782a30}WPA1 Task Instance.fields.{021e528c-060d-4eda-8bf6-d2752fc81441}dueDate': a!subtractDateTime( startDateTime: pv!event['recordType!{f07fa26e-a28d-44ca-ab58-7ba4db20200b}WPA1 Event.fields.{987c7817-ad5b-4c64-b91e-0ab1087a91ea}endDate'], days: 7 * ac!templateTask['recordType!{26443545-ab3d-444f-9cd1-fbb7ce8d789a}WPA1 Task Template.fields.{d5a9a527-bbff-429d-9849-e10b960214e4}assignedWeek'] ), 'recordType!{95d43233-0ac2-44c2-a213-4217c2782a30}WPA1 Task Instance.fields.{2866d3a9-4513-4c8c-8d73-4b84cc901bbc}name': ac!templateTask['recordType!{26443545-ab3d-444f-9cd1-fbb7ce8d789a}WPA1 Task Template.fields.{69cdc449-1e76-4725-8192-7a846f2ece52}name'], 'recordType!{95d43233-0ac2-44c2-a213-4217c2782a30}WPA1 Task Instance.fields.{fb95b4cf-a710-433a-9985-c51f1fc0a9d1}description': ac!templateTask['recordType!{26443545-ab3d-444f-9cd1-fbb7ce8d789a}WPA1 Task Template.fields.{51bb04e4-0885-412c-a597-5a811a2e1ac3}description'], 'recordType!{95d43233-0ac2-44c2-a213-4217c2782a30}WPA1 Task Instance.fields.{34de3af6-707a-4e2e-8aeb-4a5068aca485}createdBy': loggedInUser(), 'recordType!{95d43233-0ac2-44c2-a213-4217c2782a30}WPA1 Task Instance.fields.{24e8cbf2-6e65-4147-912c-356d56ee09e9}createdOn': now(), 'recordType!{95d43233-0ac2-44c2-a213-4217c2782a30}WPA1 Task Instance.fields.{2e064add-6ec2-4045-b89f-f7334e62a237}modifiedBy': loggedInUser(), 'recordType!{95d43233-0ac2-44c2-a213-4217c2782a30}WPA1 Task Instance.fields.{6c9b73fe-ab0d-40d7-998a-6c3f4b62bab1}modifiedOn': now() )
When i execute this process however the MNI Process is failing with the following errors:
I'm not referencing any maps that I know of, so I'm not sure where to look to solve this issue.
Any idea where my issue is?
Discussion posts and replies are publicly visible
Hi,
From what I can tell, the issue is related to using "is appended to list" in the output of a node that is configured as a Multiple Node Instance (MNI) with the "Run all instances at the same time" option enabled.
When this setting is used, all node instances execute in parallel, and if they all try to append to the same process variable simultaneously, you can run into race conditions.
Instead of "is appended to list", switch to "is stored at index" and store each result at tp!instanceIndex. This ensures each instance writes to a specific index in the array, avoiding concurrency issues.
tp!instanceIndex
As Mathie and Harsa mentioned, it’s usually better to avoid MNI altogether for these scenarios. Using a!forEach() in a script task or expression rule is much safer and more maintainable, since it runs sequentially and avoids shared variable conflicts.
a!forEach()
Hope this helps!
Alberto, this change fixed my issue right away. Thanks.