Script include return ,multiple value to Glide Ajax

Ketan Pandey
Tera Expert

HI All,

 

Please suggest, I am working on a requirement.  GliadeAxaj will call the Script Includet Method "Site Contacts",Which will take the take Site ID and it will return all available site contacts and vendors.

 

How the return the both Site contacts and vendors in return and how to parse those value in GlideAjax 

 

Please suggest

2 REPLIES 2

Nayan  Dhamane
Kilo Sage
Kilo Sage

Hello @Ketan Pandey ,

 

Please try below code in your script:

Script Include:

var obj = {};
obj.sitecontract= 'test';
obj.vendor= 'any vendor';

return JSON.stringify(obj);

 

 

Client Script:

var obj = JSON.parse(answer);
alert(obj.sitecontract);
alert(obj.vendor);

 

This is just an example I am aware you are getting multiple values just use the above as example and try your combinations.

If my answer solved your issue, please mark my answer as Correct & Helpful based on the Impact

Best Regards,
Nayan Dhamane
ServiceNow Community Rising Star 2023.

Community Alums
Not applicable

Hello @Ketan Pandey ,

 

If you want a function a Script Include to return multiple values you should return an object instead of one value. This object should be converted to a JSON string. This way you can retrieve it in your Client Script.

 

Please refer to Lukasz Bojara's reply here:

https://www.servicenow.com/community/developer-forum/how-to-retrieve-multiple-values-from-a-script-i...

 

@Ketan Pandey , Please mark my answer as "Accept as Solution" and "Helpfuls." If it works for you.

 

Thank you!