Skip to main content
Solved

Workflow parse outputXml using OnComplete Script

  • 14 February 2022
  • 3 replies
  • 195 views

Hi,

I created a workflow to restore a VM and for next step “WaitForJobCompletion” I have to parse the output of the execute step.
Therefore I have defined a global Variable “RestJobID” and try to set it using a OnComplete Script.

This is the OnComplete Script:

XML outputXml = utils.parseXml(xpath:{/workflow/Execute_VM-Restore/outputXml});
if (outputXml != null) {
 workflow.setVariable("RestJobID", outputXml.getText("//jobIds"));
}

I can see the JobID of the restore Job in the Log, but my script is not working as expected.
And I don’t know Java.
I spent hours searching and trying, but without success.

Could someone please give me a hint?

Thank you.

If you have a question or comment, please create a topic

3 replies

Badge +3

Hi Marc

May i know by which method in workflow you are starting the restore?

If incase you are using “Execute” inputxml Method for the restore. Please try the below and see if it works for you.

1.Add a “xpathquery” method after the restore execute method

 

2.In Input tab, at xml - value should be your outputXml of execute restore method. at xpath provide this value : /TMMsg_CreateTaskResp/jobIds[1]/@val

 

3.After this, you can call, output of xpathquery method result to waitforjobcompletion jobid input

 

Badge +1

Hi,

I created a workflow to restore a VM and for next step “WaitForJobCompletion” I have to parse the output of the execute step.
Therefore I have defined a global Variable “RestJobID” and try to set it using a OnComplete Script.

This is the OnComplete Script:

XML outputXml = utils.parseXml(xpath:{/workflow/Execute_VM-Restore/outputXml});
if (outputXml != null) {
 workflow.setVariable("RestJobID", outputXml.getText("//jobIds"));
}

I can see the JobID of the restore Job in the Log, but my script is not working as expected.
And I don’t know Java.
I spent hours searching and trying, but without success.

Could someone please give me a hint?

Thank you.

Hi Vignesh,

This is correct, I use “Execute” inputxml Method for the restore.
My problem is solved thanks to your solution, the workflow is now waiting for the Job to end.
Thanks a ton for your fast answer.

Kind Regards
Marc

Badge +1

Hi Vignesh,

This is correct, I use “Execute” inputxml Method for the restore.
My problem is solved thanks to your solution, the workflow is now waiting for the Job to end.
Thanks a ton for your fast answer.

Kind Regards
Marc