How to return a value from a script step in flow designer.

Sonu Singh
Mega Expert

Hi All,

I need to fetch a value from the response body which i have received it from the SOAP step:

Fig:

find_real_file.png

Can some help me how do i fetch any value from the xml response which i am getting in the responsebody input variable?

 

Thanks,

Ak

1 ACCEPTED SOLUTION

So the problem is the body which is returned from integration.

See formatted XML

find_real_file.png

Below works but it's not good for long time solution.

var response = inputs.response_body.toString();

var xmldoc = new XMLDocument(response);

if(xmldoc.toString().indexOf('name=') > -1){
	var nm1 = (xmldoc.toString().split('name="')[1]);
	var nm2 = (nm1.toString().split('"')[0]);
	outputs.groupname = nm2;
}

View solution in original post

41 REPLIES 41

i am getting the response with :

&lt; for <

and &gt; for >

i tried to replace this thing to proper  xml tag but that also i didn't get.

 

find_real_file.png

 

@Ankur Bawiskar  & @Mike Patel 

Can we fetch the render HTML from the above pic, because there i could see all proper and closing tags?

 

try below and see what you get in logs

var response = inputs.response_body.toString();
gs.log("response: " + response, "Soap");

var xmldoc = new XMLDocument(response);
gs.log("xmldoc: " +xmldoc, "Soap");

var name = xmldoc.getNodeText("//row/@name")
gs.log("name: "+name, "Soap");

here is log details @Mike Patel ,

find_real_file.png

Can you copy that xml and share, I can test something and if it works then I'll let you know.

@Mike Patel 

response:

<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><GetSupportSpecialistByLocationResponse xmlns="http://nda.acml.com/"><GetSupportSpecialistByLocationResult>&lt;nda-response id="getassociations" status="OK"&gt;&lt;association from_entity_guid="12345D3E-AFD1-19B1-1FD0-R3R0BF3A11EB1" business_process_role_guid="12345D3E-AFD1-19B1-1FD0-R3R0BF3A11EB1"&gt;&lt;people&gt;&lt;/people&gt;&lt;groups&gt;&lt;row group_guid="12345D3E-AFD1-19B1-1FD0-R3R0BF3A11EB1" name="IND -BLR" email="indblr@example.com" ordinal="0" description="" association_guid="12345D3E-AFD1-19B1-1FD0-R3R0BF3A11EB1"/&gt;&lt;/groups&gt;&lt;/association&gt;&lt;/nda-response&gt;</GetSupportSpecialistByLocationResult></GetSupportSpecialistByLocationResponse></soap:Body></soap:Envelope>