
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-16-2020 01:40 PM
Hi everyone!
I have a workflow which is supposed to loop through users from a list collector variable and do a handful of Orch activities. I know the data being passed into the workflow is good because one of the orchestration pieces (to update an extension attribute in the AD user record) is working fine.
I'm stuck with the Query AD and subsequent If activities. I can't seem to get to the output from the databus no matter what I do. I've referred to multiple posts here but can't get anything to work.
What I need is this:
- Query AD for the user and pull back a single attribute: extensionAttribute15
- In a subsequent If activity, determine if the value of extensionAttribute15 is equal to "o365_Licensed_Standard" or not
- If that is the value, return yes, else, return no.
- Last time I ran a test I got 'undefined' for the 'ea15' variable shown below and have no idea why
I can't get this to output even when testing on a user I know has the affirmative setting.
Here's the whole script, including some commented-out lines where you can see different things I've tried. I can confirm the 'Data' tab shows "7" next to the activity output in question.
Anyone have a suggestion? (Much appreciated in advance!)
var ea15 = '';
var qry = new JSON();
qry = qry.decode(sanitizeResults(data.get(7).output));
ea15 = qry['extensionAttribute15'];
function sanitizeResults(qry) {
qry = qry.replace(/<\/*(powershell|output)>/g, "");
qry =qry.replace(/((^\[)|(\]$))/g, "");
return qry;
}
gs.log('QUERY RESULTS FROM JSON DECODE DATA GET 7' + ea15);
if (ea15.indexOf('o365_Licensed_Standard') > -1) {
answer = 'yes';
}
else {
answer = 'no';
}
// var parser = new JSON();
// var obj = parser.decode(sanitizeResults(data.get(7).output));
// var olic = obj.extensionAttribute15;
// function sanitizeResults(obj) {
// obj = obj.replace(/<\/*(powershell|output)>/g, "");
// obj = obj.replace(/((^\[)|(\]$))/g, "");
// return obj;
// }
// if (olic.indexOf('o365_Licensed_Standard') > -1) {
// answer = 'yes';
// }
// else {
// answer = 'no';
// }
// var queryResults = new JSON().decode(data.get(7).output);
// gs.log('QUERY RESULTS FROM JSON DECODE DATA GET 7' + queryResults);
// answer = ((queryResults.length > 0 && queryResults == 'o365_Licensed_Standard') ? 'yes' : 'no');
// if (queryResults.length > 0 && queryResults.indexOf('o365_Licensed_Standard') > -1) { answer = 'yes'; }
// else { answer = 'no'; }
Solved! Go to Solution.
- Labels:
-
Orchestration (ITOM)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2020 08:26 AM
I figured it out after some more testing and tooling in the light of a new day. How I fixed it:
As I slept on it I realized I'd read others reading the output from the databus in some form of testing. I realized I could do this by going into the Custom tab in the Workflow editor > click the Query AD activity to open it > click Test Inputs > enter valid parameters and see what I get back.
When I did this I got good results.
Next I needed to figure out what kind of variable this is. So I pared it all back to basics following this KB article, logged some outputs after attempting to use array.join(), toString(), etc.
Turns out I didn't have to change anything in the Query AD activity, and below is what I ended up with in the subsequent If activity and it works! I realize the toString() bit might be superfluous but it works so I'm leaving it like this and I'm as happy as a puppy with two tails. 🙂
var ea15 = data.get(7).output;
var ea15String = ea15.toString();
if (ea15String.indexOf('o365_Licensed_Standard') > -1) {
answer = 'yes';
}
else {
answer = 'no';
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-07-2020 07:14 AM
Hello there!
As noted I was able to get this working by starting again from the KB article linked above. (https://hi.service-now.com/kb_view.do?sysparm_article=KB0635207)
If you have some specific examples/code you want to post I'd be glad to take a look. May be worth posting a new question. Good luck!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-07-2020 08:20 AM
Hi Aaron,
Thanks for the reply. I did use that KB, along with several other community posts, but am unable to isolate the name/value pair I need from the databus without [] around the value. In my case samaccountname. My output looks like /"samaccountname/":[/"username/"] I did post a question on the community, but have received no replies as of yet. I was just curious if you actually were able to completely isolate your value from the databus, and what did it look like. I know in the end, you were able to do an If with indexOf, but didn't know if you got farther than that.
Thanks anyways.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-07-2020 11:16 AM
Sorry that I'm not more help here. I found your posted question. Have you tried submitting a HI support case for this? I think if I was in your shoes that might be my next step in trying to find help. I've had good experiences w/ them if that helps. 🙂