Dubz
Mega Sage

Hi Alberto,

I'm not sure this is the best way to manage licenses but you can do it a couple of ways. It's generally considered best practice to assign roles to groups and then add users to groups so they inherit the roles, it just makes administration a bit easier. 

If you do that you can create a group with the role you need and then after an incident is created and assigned, run a check to see if the assignee as the required role and, if they don't add them to the group.

if(!current.assigned_to.hasRole('your_role')){
var gr = new GlideRecord('sys_user_grmember');
gr.initialize();
gr.user = current.assigned_to;
gr.group = 'sys_id of the group you made';
gr.insert();
}

Then you can have another after update rule running when the incident closes to find that record and delete it.

The other option is to add the role directly in the sys_user_has_role table, it's the same logic, just inserting a record into a different table.

Cheers

Dave