Skip to main content
Solved

Workflow parse outputXml using OnComplete Script

  • February 14, 2022
  • 3 replies
  • 210 views

Forum|alt.badge.img+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.

Best answer by Vignesh Sekar

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

 

View original
Did this answer your question?
If you have a question or comment, please create a topic

3 replies

Forum|alt.badge.img+3
  • Vaulter
  • 5 replies
  • Answer
  • February 14, 2022

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

 


Forum|alt.badge.img+1
  • Author
  • Bit
  • 3 replies
  • February 14, 2022
Marc S. wrote:

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


Forum|alt.badge.img+1
  • Author
  • Bit
  • 3 replies
  • February 14, 2022

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


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings