Pass Variable From Sub-workflow to Master workflow

We have a sub-workflow that adds lines to a PO, once all the lines are added, the control goes back to the master workflow and the PO is approved.

The problem we’re facing is that if one of the lines throws an error, the PO shouldn’t be approved.

I tried to solve the problem by creating two Process variable to store the error number. The idea is to pass the value of the sub-workflow variable to the master workflow variable and use it to check for errors. If the value is zero, then approve the PO. If it is not zero don’t approve it.

As the sub-workflow is adding lines, it is also checking for errors. If there is an error, it stores the value of the error number in the variable:

However, on the next iteration, the values are gone and they’re not pass to the master workflow:

How can I keep the value on the variables until all the PO lines are added and then pass it back to the master workflow?

Thanks

You have to merge it back up, honestly this is a giant pain in the butt… The way I’ve handled this is to create a UD Record where I insert the errors (at the subworkflow level) using the WorkFlowID as the unique identifier.
Then at the end of the workflow you can query that UD record and get the errors.

HOwever if you want to do without that, you could merge them back up. That means your Subworkflow needs to be “merged back” into a Dataset which contains your errors

1 Like

Do you mean create a new data container in Message Extensions and store the values there?

1 Like

@josecgomez
How do you create a UD Record in the subworkflow?

Thanks

Just bring in the dlls same as everything else