VIP Approval in the Requested for in workflow

vinod6
Tera Contributor

I want to configure dynamic approvals in a workflow by finding the VIP user within the Requested for organization's hierarchy. The VIP field is present in the user table and is set to true for both managers and their managers. VIP approval is the third level of approval in the chain, which follows this order: Requested for → Manager approval → Group approval → VIP approval.

vinod6_0-1735921527518.png

 

 

1 REPLY 1

Kieran Anson
Kilo Patron

How confident are we in the quality in the data? You can write a recursive function (example below) to walk the hierarchy but you need consider:

  • What's if a manager isn't set to VIP true
  • What's if there is no manager populated
  • What's if <some other data issue>
var walkVIPManager = function(user, recursionLimit) {

	if(recursionLimit == 0)
		return user;

    if (user.manager.nil())
        return;

    var managerGR = user.manager.getRefRecord();

    if (!managerGR.isValidRecord())
        return user; //may want to return null instead and error handle

    if (JSUtil.getBooleanValue(managerGR, 'vip') == false)
        return user; //may want to return null instead and error handle

	return walkVIPManager(managerGR, recursionLimit - 1);

	


}


var approvingUser = walkVIPManager(user /**the requestefor GlideRecord */, 3 /** Limit of how many recursions we do */)