Script include return ,multiple value to Glide Ajax
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2023 01:26 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2023 01:32 AM
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.
Best Regards,
Nayan Dhamane
ServiceNow Community Rising Star 2023.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2023 01:38 AM
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:
@Ketan Pandey , Please mark my answer as "Accept as Solution" and "Helpfuls." If it works for you.
Thank you!