Sending variable from Child Workflow to Parent Workflow

Which IIQ version are you inquiring about?

8.3

Hello i’m trying to pass a variable X from SubProcess Workflow to Parent

Parent workflow:


Initializing the variable***

<Variable name="VariableX"/>

on the step we call the subprocess workflow :

<Step xxxx>

<Return name="VariableX" to="VariableX"/>

    <WorkflowRef>

      <Reference class="sailpoint.object.Workflow" id="xx" name="Sub Workflow"/>

    </WorkflowRef>

    <Transition to="A" when="script:Boolean.TRUE.equals(VariableX)"/>

    <Transition to="Y"/>

  </Step>


Subprocess Workflow:

<Variable name="VariableX"/>

  <Step xxxx>

<Script>

//some condition then setting up the variableX to true

VariableX = true;

</Script>

      </Step>

Is this the right way to pass the variableX from subWorkflow to Parent Workflow please?

Because it doesn’t seem to work

Hi @DivyaL_7 ,

For example,

Parent workflow: LCM Provisioning

Child Workflow : Identity Request Initialize workflow

Workflow : LCM Provisioning

Passing from Parent to child:

<Arg name="plan" value="ref:plan"/>

<WorkflowRef>
      <Reference class="sailpoint.object.Workflow" id="" name="Identity Request Initialize"/>
    </WorkflowRef>

Passing from Child to Parent:

<Return name="project" to="project"/>

Thank you,

Harikrishna

Use return tag and with the help of this you can pass variables to the parent workflow. You can do it though UI or can add it directly to the XML also.

@DivyaL_7 Check this Community Article: https://community.sailpoint.com/t5/Technical-White-Papers/Workflows/ta-p/72077. Page 40/41. It explains what is return tag and how you can use it. Document is old, but approach still holds true. Also, check existing LCM Provisioning (Parent workflow) and child workflow like: Identity Request Initialize to understand how are they managing return variables.

Note: Found a fix?Help the community by marking the comment as solution. Feel free to react(:heart:,:+1:, etc.)with an emoji to show your appreciation or message me directly if your problem requires a deeper dive.

Hello thank you everyone for your answers,

I’m using the Return tag the way you mentioned but i have a problem the VariableX that is supposed to be sent to the parent workflow gets ovewritten by Parent workflow i think because i logged the variable on the subprocess workflow and it had the right value but in the parentworkflow it does get overwritten does anyone know why?

Many thanks,

You’re using <Return name="project" to="project"/> to return the variable to the parent workflow and it is still getting overwritten? Are you able to log the variable in the parent to confirm?

If possible, can you share your workflow?

Hi @DivyaL_7,

Can you please share the logs for the variable x. For variable x in parent workflow, are you initializing with the any script or rule?

Hi @DivyaL_7 ,

We had a similar case where we implemented this by storing the values in the wfContext. It works. You can use wfContext.setVariable(“manualWorkItemsOnlyNewAccount”, true); wherever you need to set the value. Then configure the argument passing so the value flows between parent and child workflows in the steps you require.

image

I hope it should work!.

Thanks,

PVR.

Hi guys thank you for your replies:

@Harikrishna_06 @robert-hails

PARENT WORKFLOW: (LCM Provisioning):

Initializing variableX:

<Variable initializer="false" name="VariableX"/>

and then in the step :

  <Step condition="script:((flow == null) ||  (!&quot;UnlockAccount&quot;.equals(flow)))" icon="Task" name="Pre Split Approve" posX="518" posY="63">

    <Arg name="approvalMode" value="ref:approvalMode"/>

    <Arg name="approvalScheme" value="ref:approvalScheme">

      <Script>

        <Source>

          import java.util.List;

          import java.util.ArrayList;

          import java.util.Iterator;

          import sailpoint.tools.Util;




          List schemes = Util.csvToList(approvalScheme);

          log.error("pre split approve step scheme = " + schemes);




          List preSchemes = new ArrayList&lt;String>();

          for (String s : Util.safeIterable(schemes)) {

          if (s.equals(approvalSplitPoint)) {

          break;

          } else {

          preSchemes.add(s);

          }

          }

          return Util.listToCsv(preSchemes);

        </Source>

      </Script>

    </Arg>

    <Arg name="requireCommentsForApproval" value="ref:requireCommentsForApproval"/>

    <Arg name="requireCommentsForDenial" value="ref:requireCommentsForDenial"/>

    <Arg name="approvalSet" value="ref:approvalSet"/>

    <Arg name="approvalAssignmentRule"/>

    <Arg name="approvingIdentities" value="ref:approvingIdentities"/>

    <Arg name="approvalSplitPoint" value="ref:approvalSplitPoint"/>

    <Arg name="fallbackApprover" value="ref:fallbackApprover"/>

    <Arg name="filterRejects" value="ref:filterRejects"/>

    <Arg name="flow" value="ref:flow"/>

    <Arg name="identityName" value="ref:identityName"/>

    <Arg name="identityDisplayName" value="ref:identityDisplayName"/>

    <Arg name="identityElectronicSignature" value="ref:identityElectronicSignature"/>

    <Arg name="identityEmailTemplate" value="ref:identityEmailTemplate"/>

    <Arg name="identityRequestId" value="ref:identityRequestId"/>

    <Arg name="launcher" value="ref:launcher"/>

    <Arg name="managerEmailTemplate" value="ref:approvalEmailTemplate"/>

    <Arg name="managerElectronicSignature" value="ref:managerElectronicSignature"/>

    <Arg name="ownerEmailTemplate" value="ref:approvalEmailTemplate"/>

    <Arg name="ownerElectronicSignature" value="ref:ownerElectronicSignature"/>

    <Arg name="project" value="ref:project"/>

    <Arg name="plan" value="ref:plan"/>

    <Arg name="policyViolations" value="ref:policyViolations"/>

    <Arg name="workItemPriority" value="ref:workItemPriority"/>

    <Arg name="securityOfficerName" value="ref:securityOfficerName"/>

    <Arg name="securityOfficerEmailTemplate" value="ref:approvalEmailTemplate"/>

    <Arg name="securityOfficerElectronicSignature" value="ref:securityOfficerElectronicSignature"/>

    <Arg name="setPreviousApprovalDecisions" value="ref:setPreviousApprovalDecisions"/>

    <Arg name="trace" value="ref:trace"/>

    <Arg name="workItemReminderTemplate"/>

    <Arg name="workItemHoursBetweenReminders"/>

    <Arg name="workItemMaxReminders"/>

    <Arg name="workItemEscalationTemplate"/>

    <Arg name="workItemHoursTillEscalation"/>

    <Arg name="workItemEscalationRule"/>

    <Arg name="workItemComments"/>

    <Description>

      Call to our standard subprocess to handle the default approvals for

      manager, owner and security officer.

    </Description>

    <Return name="approvalSet"/>

    <Return name="workItemComments"/>

    <Return name="project"/>

    <Return name="VariableX"/>

    <WorkflowRef>

      <Reference class="sailpoint.object.Workflow" id="xx" name="Provisioning Approval Subprocess"/>

    </WorkflowRef>

    <Transition to="Finalize" when="script:Boolean.TRUE.equals(VariableX)"/>

    <Transition to="Split Plan"/>

  </Step>

  

Workflow SUB:

in WORKFLOW SUBPROCESS Provisioning Approval Subprocess:

Initializing VariableX

`<Variable initializer="false" name="VariableX"/>`

and then in the step:

<Step name="StepThatIsChangingVariableX">

    <Script>

      <Source>

        VariableX = true;

        wfcontext.setVariable("VariableX",Boolean.TRUE);

        log.error("VariableX is INSIDE CHILD = " + workflow.get("VariableX"));

      </Source>

    </Script>

    <Transition to="DEBUG After"/>

  </Step>

 

  <Step name="DEBUG After">

    <Script>

      <Source>

        import sailpoint.object.ApprovalSet;

        import sailpoint.object.ApprovalItem;

        import sailpoint.object.WorkItem;

        import org.apache.log4j.Logger;

        import java.util.ArrayList;

        import sailpoint.object.Comment;


        Logger log = Logger.getLogger("sailpoint.workflow.expiry");



        log.error("VariableX is AFTER CHILD harris -------= " + VariableX);

      </Source>

    </Script>

    <Transition to="end"/>


So in the parentWorkflow the value of VariableX is always false, but in the subProcessWorkflow it is true..

Also just so i’m sure that the error is not coming from using boolean values i switched VariableX to a string “Activate” but it is still the same scenario the value of VariableX doesn’t get sent to the parent workflow either in string form or boolean form

Hi @DivyaL_7 ,

We had a similar case where we implemented this by storing the values in the wfContext. It works. You can use wfContext.setVariable(“manualWorkItemsOnlyNewAccount”, true); wherever you need to set the value. Then configure the argument passing so the value flows between parent and child workflows in the steps you require.

image

I hope it should work!.

Thanks,

PVR.

Hi @DivyaL_7 ,

Can you try returning the variableX like resultVariable=“VariableX” in the step modifying the value of X in subprocess workflow.

<Step name="StepThatIsChangingVariableX" resultVariable="VariableX">

    <Script>

      <Source>

        VariableX = true;

        wfcontext.setVariable("VariableX",Boolean.TRUE);

        log.error("VariableX is INSIDE CHILD = " + workflow.get("VariableX"));

      </Source>

    </Script>

    <Transition to="DEBUG After"/>

  </Step>

 

  <Step name="DEBUG After">

    <Script>

      <Source>

        import sailpoint.object.ApprovalSet;

        import sailpoint.object.ApprovalItem;

        import sailpoint.object.WorkItem;

        import org.apache.log4j.Logger;

        import java.util.ArrayList;

        import sailpoint.object.Comment;


        Logger log = Logger.getLogger("sailpoint.workflow.expiry");



        log.error("VariableX is AFTER CHILD harris -------= " + VariableX);

      </Source>

    </Script>

    <Transition to="end"/>

I have tried this way, and it is working.

Hello @Chathurya thank you for your reply,

I tried it but the resultVariable sets the variable in the subprocess workflow but i still have the same problem where in the parent workflow the value is not sent and is null…

@DivyaL_7,

Try this one to get the variable value from the workflow context, we got the value without issue!

return wfcontext.getVariable(“manualWorkItemsOnlyNewAccount”);

it will give the value.

Thanks,

PVR.

Hello @Peddapolu , thank you for your reply,

I tried it but still not working.. I don’t think using an <Arg> is appropriate here, since arguments are passed from the parent workflow to the child workflow.
What I actually need is the opposite: I set the value in the child workflow using wfcontext.setVariable(...), and then I want to retrieve that value in the parent workflow so i can use it to transition to another step..

Hi @DivyaL_7 ,

In the parent workflow modify this below line

<Return name=”'VariableX”/>

To:

<Return name="VariableX" to=”VariableX”/>

It will solve your issue

Thankyou

Harikrishna

@DivyaL_7 I tested this with a simple sample workflow and if i return a variable from child workflow to parent workflow, then value from child WF is available in the parent wf. Please check the attached workflow and rule and see if you have configured in the same way.

TestWF2.xml (792 Bytes)

TestWF1.xml (1.1 KB)

testRule.xml (525 Bytes)

Hi Divya,

Only thing I see may be missing in your code is setting output=“true” for your variable. It should be set in your sub process.

  <Variable name="VariableX" output="true"/>

Apologies, you need to put the value into the workflow object, not the wfcontext. It’s returning values for sub workflows and parent workflows. Here it is: if you don’t put the value in the workflow object, the value won’t be set in the sub workflow.

Sub workflow

parent workflow

parent workflow out put:

I hope it should work!.

Thanks,

PVR.

Hello @DivyaL_7 ,

I hope you are doing well!
Do you still have issues? Let us know if the above threads work!.

If it works, please mark it as the solution.

Thanks,

PVR.