Checking user role in flow designer

saikumarkak
Tera Contributor

saikumarkak_0-1754892516251.png

i wrote the script that selected user has the admin role the the flow should be continue. here when tesing i am getting this error message. "Error: Cannot read property "variables" from null,Detail: Cannot read property "variables" from null"

saikumarkak_1-1754892695040.png

 

1 ACCEPTED SOLUTION

Viraj Hudlikar
Giga Sage

Hello @saikumarkak 

When I tried with below code in script part where you check and set value of flow variable, I also did same, and it worked for me. Have a look and give try.

//fd_data.trigger.request_item.variables.<variable name>.sys_id;
var a = fd_data.trigger.request_item.variables.affected_user.sys_id;

//checking by passing user sys_id and if it has role admin
var b = gs.getUser().getUserByID(a).hasRole('admin');

//return of value is it true or false.
return b;

 

VirajHudlikar_0-1754897743784.png

VirajHudlikar_1-1754897759579.png

 


If my response has helped you hit helpful button and if your concern is solved do mark my response as correct.

 

Thanks & Regards
Viraj Hudlikar.

View solution in original post

5 REPLIES 5

Viraj Hudlikar
Giga Sage

Hello @saikumarkak 

When I tried with below code in script part where you check and set value of flow variable, I also did same, and it worked for me. Have a look and give try.

//fd_data.trigger.request_item.variables.<variable name>.sys_id;
var a = fd_data.trigger.request_item.variables.affected_user.sys_id;

//checking by passing user sys_id and if it has role admin
var b = gs.getUser().getUserByID(a).hasRole('admin');

//return of value is it true or false.
return b;

 

VirajHudlikar_0-1754897743784.png

VirajHudlikar_1-1754897759579.png

 


If my response has helped you hit helpful button and if your concern is solved do mark my response as correct.

 

Thanks & Regards
Viraj Hudlikar.