Non Production Environment access

Saumil Parekh
Tera Contributor

Requirement

Access provisioning for non-admin accounts is fulfilled automatically in non-prod environments using ServiceNow catalog

Note - Non-admin accounts include ITIL user & Impersonator access type

Catalog item is already in placed want to achieve the access to non-prod environment automatically

1 ACCEPTED SOLUTION

var user = current.variables.user; // considering sysid of user

var role = current.variables.role; // considering sysid of role

var group = current.variables.group; // considering sysid of group

 

If you want to give access directly as role

var userRole = new GlideRecord("sys_user_has_role");

userRole.initialize();

userRole.user = user;

userRole.role = role;

userRole.insert();

 

If you want to give access directly as group

var userGroup = new GlideRecord("sys_user_grmember");

userGroup.initialize();

userGroup.user = user;

userGroup.group= group;

userGroup.insert();

 

 

View solution in original post

5 REPLIES 5

Ratnakar7
Mega Sage

Hi @Saumil Parekh,

 

There are many ways to achieve this requirement, one is using REST -Table API.

 

Request

HTTP Method / URI
POST https://<non-prod-env-instance>.service-now.com/api/now/table/sys_user_has_role
 
Headers
Content-Type : application/json
Accept : application/json
 
Request Body
{"user":"9c5063371bd461109c2455f3604bcb23","role":"bca873d30a000704013944bd9a5e03a4"}


You can call above non-prod environment REST_API  method in Service Catalog's workflow to push ITIL user and impersonator role to non-admin account automatically by passing sys_ids.

 

Regards,

Ratnakar