- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2023 09:04 PM - edited 01-16-2023 09:06 PM
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
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2023 10:02 PM
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();
Please mark correct if my response has solved your query.
Cheers,
Mohammed Basheer Ahmed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2023 10:29 PM
Hi @Saumil Parekh,
There are many ways to achieve this requirement, one is using REST -Table API.
Request
Headers
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