Possible to Isolate Trigger to Activate by Group of Users

emorganisc
Tera Contributor

Hi all, I was wondering if it is at all possible in any sort of way to limit the "when to run" exclusion in flow designer for a trigger to a group of users instead of maintaining a list of cherry picked individual users?

  • Do not run if triggered by the following users: Specify a list of users who cannot execute the flow.
  • Only Run if triggered by the following users: Specify a list of users who can execute the flow.emorganisc_0-1707612564418.png

     

Any advice is greatly appreciated, the current method of having to maintain this without groups is very frustrating!

1 ACCEPTED SOLUTION

That's no problem, you can create a TRUE/FALSE Flow Variable and set it to either true or false to indicate the 'updated_by' is part of the group. And you can use that within your IF Flow activity.

 

For example, you can refer to the following script for setting your true/false Flow variable

JamesChun_0-1708459344273.png

var runFlow = false;
if(gs.getUser().getUserByID(fd_data.trigger.request_item.sys_updated_by.toString()).isMemberOf(fd_data.flow_var.mygroup.getValue('name')))
{
    runFlow = true;
}
return runFlow;

You can modify the script above with your parameters.

 

Then use IF Flow action like below

JamesChun_1-1708459403618.png

 

Hope it helps, thanks.

View solution in original post

7 REPLIES 7

emorganisc
Tera Contributor

Hi, I would greatly appreciate any advice anybody has!

James Chun
Kilo Patron

Hey @emorganisc,

 

I haven't seen this before but there is definitely room for improvement!

A few ideas that I can think of as a workaround:

  • Use an 'If' statement to check if the user is part of the group, if not terminate Flow immediatelyJamesChun_0-1708130176466.png
  • Trigger Flow via Business Rule and validate if the user is in the group in the BR

Additionally, consider raising an Idea to ask ServiceNow to implement this functionality in the future release!

 

Hope it helps, thanks!

 

Thanks James, I tried setting it up in Flow Designer but it doesnt seem to work as you have it set up. I can't find a way to pull out group membership info from the group record, so there is no way to check against a user as part of a group.

No worries @emorganisc,

 

Did you mean the 'Flow Variables > allowedUsers' data pill?

 

You can create a Flow Variable within the Flow Designer.

JamesChun_1-1708399084724.png

 

JamesChun_0-1708399043145.png

 

And then you can assign a value to it within Flow action

JamesChun_2-1708399173380.png

 

Thanks