- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2018 08:19 AM
Hi community,
I've got a workflow run script activity that is calling a script include, passing it a couple values, and then I need the script include to pass back 2 values from a GlideRecord. To do this I'm trying to build a JSON object to handle the 2 values being passed back to the workflow. I'm not sure if my JSON object script is correct, and as well I'm not sure what the script needs to be in the workflow activity to consume the returned data. Any help would be great, thanks!
Here's the script include script...not if sure this is correct:
var gr = new GlideRecord('u_ad_group_lookup');
gr.addQuery('u_user_ad_domain',adDomain);
gr.addQuery('u_application',application);
gr.query();
if(gr.next()){
var json = new JSON();
var object = {
'adGroup' : gr.getValue('u_ad_group'), //first value I need to pass back
'adDomain' : gr.getValue('u_group_ad_domain') //second value I need to pass back
};
var data = json.encode(object);
gs.info('returned data is '+data);
return data;
And here's the workflow script...quite sure this is not correct:
var application = workflow.scratchpad.application; //first parameter to pass to script include
var userDomain = workflow.scratchpad.user_domain; //second parameter to pass to script include
var obj = new u_ActiveDirectoryGroup_lookup(); //name of my script include
var returnedData = obj.GetUserADGroup(userDomain, application); //name of my function with passed values
var adGroup = returnedData.adGroup; //first value I'm trying to receive from script include
var adDomain = returnedData.adDomain; //second value I'm trying to receive from script include
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2018 08:51 AM
Hi,
Use this:
var returnedData = obj.GetUserADGroup(userDomain, application);
var obj = JSON.parse(returnedData);
then use obj.adDomain
Thanks,
Ashutosh

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2018 08:24 AM
HI,
Use this script:
var gr = new GlideRecord('u_ad_group_lookup');
gr.addQuery('u_user_ad_domain',adDomain);
gr.addQuery('u_application',application);
gr.query();
if(gr.next()){
var str = {};
str.adGroup = gr.getValue('u_ad_group'); //first value I need to pass back
str.adDomain =gr.getValue('u_group_ad_domain'); //second value I need to pass back
var data = json.stringify(str);
gs.info('returned data is '+data);
return data;
Thanks,
Ashutosh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2018 08:27 AM
Hi Ashutosh,
thanks for the reply, I'll try that. Is my workflow script correct?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2018 08:32 AM
One thing, with my script I am getting this from my script include log entry:
returned data is {"adDomain":"CORP","adGroup":"Okta-CORP-App-SAPBusinessObjectsCloud"}
these are the 2 values I need, is it possible to pull these out in my workflow script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2018 08:44 AM
Here's my latest workflow script...I am receiving the json object correctly...how do I parse out the individual pieces?
Here's the log entry, so I know I'm getting the json correctly...just not successfully pulling them out.
returnedData is {"adDomain":"CORP","adGroup":"Okta-CORP-App-SAPBusinessObjectsCloud"} and adGroup is undefined and adDomain is undefined
and here's my workflow script creating this log:
var application = workflow.scratchpad.application;
var userDomain = workflow.scratchpad.user_domain;
var obj = new u_ActiveDirectoryGroup_lookup();
var returnedData = obj.GetUserADGroup(userDomain, application);
var adGroup = returnedData.adGroup; //guessing this is wrong
var adDomain = returnedData.adDomain; //guessing this is wrong
gs.info('returnedData is '+returnedData+' and adGroup is '+adGroup+' and adDomain is '+adDomain);