Hi All, i'm new to Orchestrator and trying to build workflows to veeam Backup and replication
doing a rest query and get the following response
<?xml version="1.0" encoding="utf-8"?>
<Task Href="https://URL:9398/api/tasks/task-57" Type="Task" xmlns="http://www.veeam.com/ent/v1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Links>
<Link Href="https://URL:9398/api/tasks/task-57" Rel="Delete"/>
</Links>
<TaskId>task-57</TaskId>
<State>Running</State>
<Operation>EditJob</Operation>
</Task>
Trying to extract the TaskId, so my expected return is "task-57"
PostResponse.contentAsString = the XML i posted earlier.
Code Start:
// check the task if it failed or succeed
var strXMLresponse = PostResponse.contentAsString
var XMLdoc = XMLManager.fromString(strXMLresponse);
if (!XMLdoc) {
errorCode = "Invalid XML Document";
throw "Invalid XML Document";
}
var referenceElementList = XMLdoc.getElementsByTagName("Task");
var numOfReferences = referenceElementList.length
System.Log(numOfReferences)
if (numOfReferences == 0) {
errorCode = "Invalid XML Document - name element missing";
throw "Invalid XML Document";
}
// Get the Task ID.
var ref = referenceElementList[0]; // element 0 is first element in the array.
var strtaskid = ref.getAttribute("Result");
System.log(strtaskid);
Output is:
[2019-01-16 11:34:29.067] [E] Error in (Workflow:Scriptabletesting / Scriptable task (item1)#37) TypeError: Cannot find default value for object.
[2019-01-16 11:34:29.083] [E] Workflow execution stack:
***
item: 'Scriptabletesting/item1', state: 'failed', business state: 'null', exception: 'TypeError: Cannot find default value for object. (Workflow:Scriptabletesting / Scriptable task (item1)#37)'
workflow: 'Scriptabletesting' (9463b203-25b1-48ab-8e96-931b4341a971)
| 'attribute': name=objvbrhost type=REST:RESTHost value=dunes://service.dunes.ch/CustomSDKObject?id='16043dac-629d-4502-b0a0-366007d1ec06'&dunesName='REST:RESTHost'
| 'attribute': name=strjobid type=string value=06905e74-39aa-4183-848b-a848de7cab50
| 'no inputs'
| 'no outputs'
*** End of execution stack.
been working through w3schools XML DOM - Get Node Values guide. but can't seem to get past this roadblock.
Hi,
vRO uses Rhino Javascript engine, which is a server-side JS, and there is no client DOM.
The error you are getting is unrelated to XML processing; it is due to misspelled System.Log() which should be System.log() - whit lowercase 'l'.
Even after fixing this typo, your code won't work. The correct code could be something like the following:
var strXMLresponse = PostResponse.contentAsString
var XMLdoc = new XML(strXMLresponse);
var veeamns = new Namespace("http://www.veeam.com/ent/v1.0");
System.log(XMLdoc.veeamns::TaskId);
Hi,
vRO uses Rhino Javascript engine, which is a server-side JS, and there is no client DOM.
The error you are getting is unrelated to XML processing; it is due to misspelled System.Log() which should be System.log() - whit lowercase 'l'.
Even after fixing this typo, your code won't work. The correct code could be something like the following:
var strXMLresponse = PostResponse.contentAsString
var XMLdoc = new XML(strXMLresponse);
var veeamns = new Namespace("http://www.veeam.com/ent/v1.0");
System.log(XMLdoc.veeamns::TaskId);
Thanks for the code, and for the pointer to Rhino Javascript, gives me a direction to go for documentation.
Anywhere you would recommend for me to go to read up on how to work with XML in orchestrator?
Just starting out and keep having troubles. haven't been able to fine any documentation around the syntax you're using for working around XMLs apart from the ones i linked above.