Hi everyone,
I have a scriptask which create an output of type text by running an expression rule, which looks like below:
I save this output into a process parameter, then plan to use it for the sub-process.
If I want to take the updatedRelationship of the current process instance, what the script should be like?
I tried below code but the data does not pass into sub-process... do I need tp!instanceIndex for the process to know what data to pass into its subprocess?
index(pv!scriptaskOutcome,"updatedRelationships",tp!instanceIndex, null)
Thank you!
Discussion posts and replies are publicly visible
Hi, are you using MNI on subprocess? if not then you dont need to use tp!instanceIndex. Just index into correct output from the process variable.
I just checked, seems like tp!instanceIndex is needed... I'm I right?
In this case you aren't using the option for "Automatically run multiple instances of this node", so the tp!instanceIndex variable won't have a value.
It's still unclear to me what you are trying to do - are you trying to create a different sub-process for each item in your list of "updatedRelationships"? If so, then you need to check that box above and then tp!instanceIndex will work. If you're not doing that, are you trying to pass a certain index (e.g. the first item)? If so, you can just hardcode 1 into your index() function above. Or another option is you can just pass the entire list into the sub-process and use it there however you need to.
Hi Peter, I want to use the expression output values as the input variables for my sub-process (fileId, relationshipToRemove, updatedRelationships, documentDetails, runDocumentCleanUp, etc. ), below is what I'm doing at the moment:
However, I tested and the values didn't pass into subprocess successfully. I tried your recommendation of removing the "tp!instanceIndex" and it didn't work either....
As Peter noted, tp!instanceindex is not available until you actually configure the node to run as MNI using this checkbox:
After selecting the "Automatically run multiple instances of this node" option you have to define how many instances of this subprocess will have to run. In the expression editor next to the "Run this many" option you have to insert the following piece of code:
count( index( pv!scriptaskOutcome, "updatedRelationships", "entityId", null ) )
I'm using count() function and not length() because it's counting the null values also of the entityId
Hi Mollyn,
I see you you are providing 4 values inside index function - index(pv!scriptaskOutcome,"updatedRelationships",tp!instanceIndex, null). it may be causing your issue. try update your index function it may solve your problem. I would suggest debug this issue first by passing the entire list to your sub process without running MNI and see if the values are coming to sub process or not.
ex: index(pv!scriptaskOutcome,"updatedRelationships", null)
The problem is that he has not configured the subprocess node to run as an MNI and at the same time he is using the tp!instanceIndex variable. The expression index(pv!scriptaskOutcome,"updatedRelationships",tp!instanceIndex, null) will work fine if he makes the MNI config.
Thanks for the detailed explaination Dimitris. I did configure the MNI and paste below code into the Run as many box
However the sub process still wasn't able to receive any value. I guess it's the issue with the sciptask outcome data type or the index() thing.
Could you check pv!scriptaskOutcome has any value in the instance or not. And what is the datatype configured for this variable is it of type Map which allows multiple values?