- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-22-2024 07:59 PM
I created a subflow so that I could call it in a legacy workflow. All it does it query whether a user is a member of an AD group. When I call it in a workflow using a script activity it returns true. Yet when I call it from a background script or directly from flow designer with the same inputs I get false which is what I am expecting because the user is not in the AD group.
********Background Script*************
var inputs = {};
inputs['user'] = 'secyorkb'; // String
inputs['group'] = 'SN.03 Test Related App - SOC1'; // String
// Execute Synchronously: Run in foreground. Code snippet has access to outputs.
var result = sn_fd.FlowAPI.getRunner().subflow('global.is_user_in_group').inForeground().withInputs(inputs).run();
var outputs = result.getOutputs();
// Get Outputs:
// Note: outputs can only be retrieved when executing synchronously.
var is_member = outputs['is_member']; // True/False
gs.addInfoMessage('XX: outputs ' + is_member); ----> This returns false
************Subflow***************
***********Workflow Script Activity*************
I hard coded the values to make sure it would definitely use the same data
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-30-2024 06:13 AM
It turns out that though I was passing in a string to function it was treating it as an object for some reason. Once I added .toString() it works fine.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-22-2024 08:10 PM
Hello @Community Alums
Try using log statements to check what values the script is returning at each step.
Also, I beleive the Workflow script runs Asynchronously. And the flow here running synchronously.
There might be issue because of that
Please Mark this answer as helpful and correct if helped.
Kind Regards,
Ravi Chandra
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-22-2024 08:41 PM
Even if I put a 2min wait on that activity it still returns incorrectly. Running it from backgroud script its totally fine.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-22-2024 09:13 PM
What's odd is that I am calling this sublow synchronously from the run script activity so it should wait for it to complete but it doesn't appear to do so. I if I run this from a background script it take maybe 5-10 seconds to run but in the workflow it gets past the script activity almost instantly. It's like it's not waiting for the subflow to complete.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-22-2024 09:48 PM
2024-05-22 22:45:48 | Information | XX: here4 | *** Script | ||
Select record for action: Created 2024-05-22 22:45:48 | 2024-05-22 22:45:48 | Information | XX: here3 | *** Script | |
Select record for action: Created 2024-05-22 22:45:48 | 2024-05-22 22:45:48 | Information | XX: action Add isMember null | *** Script | |
Select record for action: Created 2024-05-22 22:45:48 | 2024-05-22 22:45:48 | Information | XX: outputs nullnull | *** Script | |
Select record for action: Created 2024-05-22 22:45:48 | 2024-05-22 22:45:48 | Information | XX: inputs secyorkbTEST | *** Script | |
Select record for action: Created 2024-05-22 22:45:48 | 2024-05-22 22:45:48 | Information | XX: group - TEST | *** Script | |
Select record for action: Created 2024-05-22 22:45:48 | 2024-05-22 22:45:48 | Information | XX: here2 | *** Script | |
Select record for action: Created 2024-05-22 22:45:48 | 2024-05-22 22:45:48 | Information | XX: here1 | *** Script | |
Select record for action: Created 2024-05-22 22:45:48 | 2024-05-22 22:45:48 | Information | XX: user secyorkb | *** Script |