Automatically assigning approver_user role to the user who gets requests for approval

Amith3
Kilo Contributor

Hello All,

We have to develop a solution so that when a user has an approval (Table = sysapproval_approver) assigned to them so that something automatically allocates to them the approver user role. If user already has approver_user role then ignore.

We have found that when a user gets an automated approval from a request if they don't have approver_user role they can't see the approval in the Service Portal to approve/reject the request. We need an automated way of assigning approver_user role to only people who need to approve requests (not everyone does).

Any idea on how to achieve it?

PS: I am not much into ServiceNow Development and if possible requesting to help me with the code please.

2 REPLIES 2

sachin_namjoshi
Kilo Patron
Kilo Patron

First, note that "approver_user" is licensed role and you should track usage of this license.

Also, in your service portal widget, you can create your own widget to allow any users without any role to approve records.

 

Regards,

Sachin

jacob_kimball
ServiceNow Employee
ServiceNow Employee

Agreed with the previous comment about licensing impacts, but that being said programmatically you can do this by:

  • Create a group that all of the people who need the role would belong to that has that role assigned (ServiceNow best practice for role management).
  • Creating a flow (using Flow Designer) on the sysapproval_approver table that fires on record creation on the sysapproval_approver table.
  • The flow would have an "Create or Update Record" step where:
    • The table was Group Members (sys_user_grmember).
    • Field mapping for group where it was your approval group from bullet #1
    • Field mapping for the user where the value is pulled in from a data pill on the triggering record (from sysapproval_approver) for the user reference.
    • Both of the field mappings have 'Determines uniqueness' checked. 

 

This should create the group membership record or will just 'coalesce' to it if it already exists.  No code needed as it uses the platform flow capabilities...and can happen async or sync as you desire!