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

@Mike Patel 

gs.log i didn't logged anything in syslog_list so. i passed those value to output.

find_real_file.png

try

var response = inputs.response_body.getDisplayValue();
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");

Hi,

I could see null in the name variable?

Did you not get the proper xml response?

Regards
Ankur

 

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Mike Patel  & @Ankur Bawiskar 

 

 

 

No image