ITIL role automatically assign to user , when manager approve the request , please check my code ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2024 01:13 AM
Script :-
var itil = new GlideRecord('sys_user_has_role');
itil.initialize();
itil.user = current.variables.requested_for; // instead of u_requested_for add the variable name of the catalog request form
itil.role = '282bf1fac6112285017366cb5f867469'; //sys_id og the ITIL role record
itil.insert();
This Script i'm using but it's not working for me
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2024 01:33 AM - edited 01-04-2024 01:33 AM
Hi @1dusjhyahnt,
I've checked your script on a vanilla Personal Dev Instance via a Background script, and it looks to work as intended. I've substituted the 'current.variables.requested_for' with the sys_id of good old user abel.tuter - See below and test/run this via 'Scripts - Background'.
Have you confirmed your script returns the sys_id where you're using the line: 'current.variables.requested_for' ?
I'd also recommend and guide you to best practice and not add a role to an individual user/users, instead, add the users to a group where the users inherit the role/roles via group membership.
To help others, please mark correct and helpful.
Thanks,
Robbie