run loop script task for items in list and pass the value of a field in that map to a sub process fetching that value.

Hello community, I am exploring the loop functionality of a scrip task but can't figure out how to do the following.

I have a list of  6 map entries (same structure) with e.g. 4 fields and want to pass the values of the field of each map entry to a subprocess for earch entry fetching the values. 
I use pv!listOfMap[tp!instanceindex] to get the values. But what happens is that the script task iterates  6 times first and passing the last value of index 6, to 6 instances of the sub process. So ending with 6 instances 
with only the last value, instead of 1 to 6. I know I can pass the list of maps to the sub process and also pass the [tp!instanceindex] as a variable, and use the index in the sub process. But what am I doing wrong here?

Kind Regards,


  Discussion posts and replies are publicly visible

  • Hi Erik

    A little difficult to understand what's going on form your description...but let's try and separate this into a smaller set of problems to solve:

    1. generating the array of map - I would strongly recommend you use an Expression Rule to do this. In this way you can build and test and prove that you are generating the required data correctly, and that the output is both of the correct type and content
    2. Now hook this Expression up to a Script Task in your process model. Ensure that the output of the Script Task is mapped to a pv! of the correct type (as output by your Expression Rule) and is also set as a 'multiple' (i.e. an array)
    3. Run the process JUST with this script Task and prove to yourself that the data in the pv! is correct
    4. Add your sub-process, ensure that the input variable to the sub-process is of the correct type for a single instance of your data in the pv!
    5. Set your sub-process as an MNI and map your pv! to the input variable to your sub-process - note: you do NOT need to use tp!instanceIIndex in this scenario - Appian is clever enough (in this context) to pass the correct item in your array to each sub-process instance (using tp!instanceIndex works but is unnecessary here)

    I would also run the whole thing in debug mode again at this point and prove to myself that the individual sub-process instances contain the correct individual item from your array