Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Make UI action visible to users with certain role only

ebaileyybs
Tera Expert

Hi,

 

I have created the following UI action for the creation of a project record from another table.

 

Condition: !current.project.hasValue()

 

Script:

var project = new GlideRecord("pm_project");

project.u_name = current.u_project_name;

project.description = current.description;

var sysID = project.insert();

current.u_project =   sysID;

var mySysID = current.update();

 

gs.addInfoMessage("Project " + project.number + " created");

action.setRedirectURL(change);

action.setReturnURL(current);

 

I would like to make this UI action available to users with the project_manager role only.

 

How do I add this to the script'?

 

Thanks in anticipation.

Emma

1 ACCEPTED SOLUTION

Michael Fry1
Kilo Patron

add gs.hasRole('project_manager') to your condition.



!current.project.hasValue() && gs.hasRole('project_manager')


View solution in original post

2 REPLIES 2

Michael Fry1
Kilo Patron

add gs.hasRole('project_manager') to your condition.



!current.project.hasValue() && gs.hasRole('project_manager')


poyntzj
Kilo Sage

Make the condition


!current.project.hasValue() && gs.hasRole('project_manager');