How to use if condition gs.getuser().ismemberof in flow designer

Rajveer
Tera Expert

Hi Experts,

How to use  if condition of following script in flow designer. gs.getuser().ismemberof('current.cmdb_ci.support_group')

Regards 

Rajveer

1 ACCEPTED SOLUTION

Tested with below.

1. Inputs: cmdb_ci is of type "Reference.Configuration Item"

find_real_file.png

2. Script step: Input Variable name is "supportGroup" and Value is "action -> cmdb_ci -> Support group -> Name".  I just selected it from data pill on the right side of the page under "cmdb_ci" > Support group" > "Name".

Created Output Variables named "ismember" (Label is "isMember") of type "True/False".

 

find_real_file.png

find_real_file.png

3. In my Configuration Items table, there is a record named "apache linux den 200" that has Support group "IT Securities". I've added myself as a member of group "IT Securities".

find_real_file.png

4. Test the created action. Select "apache linux den 200" as input.

find_real_file.png

5. Test result is "true".

find_real_file.png

6. Rerun the test but this time select "Blackberry" that has "Support group" set to "Capacity Mgmt" which I'm not a member of.

find_real_file.png

7. Test output returns "false".

find_real_file.png

View solution in original post

17 REPLIES 17

Try the following.

JavaScript differentiates upper and lower cases so use .getUser().isMemberOf().

Also, I've made the input variable name to the Script step "supportGroup" and assigned "action->approval->Support group->Name

(function execute(inputs, outputs) {
  if (gs.getUser().isMemberOf(inputs.supportGroup)) {
    outputs.ismember = true;
  } else {
    outputs.ismember = false;
  }
})(inputs, outputs);

find_real_file.png

find_real_file.png

Hi Hitoshi,

Thanks for reply

It's not working for me 

 

Regards

Rajveer

Hi,

please share your script step and the action etc

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Tested with below.

1. Inputs: cmdb_ci is of type "Reference.Configuration Item"

find_real_file.png

2. Script step: Input Variable name is "supportGroup" and Value is "action -> cmdb_ci -> Support group -> Name".  I just selected it from data pill on the right side of the page under "cmdb_ci" > Support group" > "Name".

Created Output Variables named "ismember" (Label is "isMember") of type "True/False".

 

find_real_file.png

find_real_file.png

3. In my Configuration Items table, there is a record named "apache linux den 200" that has Support group "IT Securities". I've added myself as a member of group "IT Securities".

find_real_file.png

4. Test the created action. Select "apache linux den 200" as input.

find_real_file.png

5. Test result is "true".

find_real_file.png

6. Rerun the test but this time select "Blackberry" that has "Support group" set to "Capacity Mgmt" which I'm not a member of.

find_real_file.png

7. Test output returns "false".

find_real_file.png

Hi Hitoshi,
 
I tried same as you suggested
But still it's not working 
 
Following are screenshot for your reference.
 
I added to me in "IT security" group.
 
find_real_file.png
 
 
find_real_file.png
find_real_file.png