MNI Sub-Process only returns last result — how to collect all outputs?

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.

Goal: Collect all processed items into pv!updatedAccounts[].

Current setup:

  • Parent PVs:
    • pv!accounts (array)
    • pv!updatedAccounts (array)
    • pv!childResult (single)
  • Sub-Process:
    • Input: accountHeader <- fv!item
    • Output: pv!childResult <- accountHeader

Fix I’m trying:

  • Add a Script Task after the Sub-Process.
  • Enable MNI on the Script Task (same array).
  • In Script Task Outputs:
    Plain Text
    appian isn’t fully supported. Syntax highlighting is based on Plain Text.
    a!save(pv!updatedAccounts[fv!index], pv!childResult)
    Show more lines
  • Merge branches with an AND Gateway.

Questions:

  1. Is enabling MNI on the Script Task the best way to use fv!index?
  2. Can Sub-Process Output Target be switched to expression mode for pv!updatedAccounts[fv!index] (to skip Script Task)?
  3. Any tips for error handling per instance?

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    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.

  • 0
    Certified Lead Developer
    in reply to Mike Schmitt

    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.

Reply
  • 0
    Certified Lead Developer
    in reply to Mike Schmitt

    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.

Children
No Data