Reassign an approval to another user

phanita mylapur
Tera Contributor

Hi  ,

I am new to servicenow development  ,i have a requirement to  'Reassign an approval to another user'  in ritm.can you help me on this

Ex: If a  ticket is icorrectly assigned a request that needs approval from different  user,need to  re-assign  the ticket to different user for them to approve

 

 

regards,

phanita

1 REPLY 1

Tushar
Kilo Sage
Kilo Sage

Hi @phanita mylapur 

 

The below BR will work to reassign an approval to the new assignee if the approval user is different from the new assignee.

 

(function executeRule(current, previous) {
  // Get the current approval user.
  var approvalUser = current.getValue('approval');

  // Get the new user to whom the ticket is being reassigned.
  var newAssignee = current.getValue('assigned_to'); // Assuming 'assigned_to' is the field that represents the new assignee.

  // Check if the approval user is different from the new assignee.
  if (approvalUser != newAssignee) {
    // Reassign the approval to the new assignee.
    current.setValue('approval', newAssignee);
  }
})();

 

Please, don't forget to mark my answer as correct if it solves your issue or mark it as helpful if it is relevant for you!

Regards,
Tushar