I have a parent PM that passes a list of AOM_AccountHeader to a child PM (which accepts a single item). Using MNI on the Sub-Process works, but when I map the child’s accountHeader directly to pv!updatedAccounts in the parent, I only get the last instance result.
AOM_AccountHeader
accountHeader
pv!updatedAccounts
Goal: Collect all processed items into pv!updatedAccounts[].
pv!updatedAccounts[]
Current setup:
pv!accounts
pv!childResult
accountHeader <- fv!item
pv!childResult <- accountHeader
Fix I’m trying:
Questions:
fv!index
pv!updatedAccounts[fv!index]
Discussion posts and replies are publicly visible
This has long been a weakness in using MNI configurations for something you need to collect a batch of results for in the parent. From my experience, and unless anything has changed that has eluded me so far, the simplest by far has been to abandon MNI in such cases and simply configure a manual in-process loop that iterates over the same subprocess node once in each loop, passes the result CDT (etc) back to the parent, then in a script task after the subprocess node, append that result to a "running" list of results, before looping back to the subprocess for the next iteration. You would maintain a counter in the parent process PVs and use it to determine in an XOR gateway whether the looping is finished or not.
Note that the new Start Process node, using Synchronous settings, has far more flexible "output variable" configurations, and I haven't played around with this extensively enough yet to know for sure, but it MIGHT now be possible to do this appending operation there instead of manually building an in-process loop. But then, maybe not. But it might be worth looking into briefly.
So I just whipped up a quick, 2-model test for this, and I can verify it seems to work.
The subprocess called here simply queries from our "Person" table via PersonId and saves the output into a (single) Person-type PV named "person" (how original). Then in the parent we call that subprocess via the Start Process node, synchronous, configured for MNI, and set the output (the subprocess PV has to be manually set in the "value" box by expression as it doesn't appear in the picker, presumably because the subprocess's value is single and the parent process's PV is multiple, which seems like an oversight to me on Appian's part for this use case). The operator is "append", as seen in my screenshot.
After being run, the resulting parent process "resultPersonCdtList" contains all queried values. Note: you can configure the MNI to either "launch all at once" (faster) or "one at a time", but only "one at a time" causes the resulting array's order to match the original list.