Delegation - Approvals different types

poyntzj
Kilo Sage

Delegation,   Great at allowing us to delegate approvers amongst other things.

Has anyone enhanced this to split the types of approval ?

What I mean is if a user is off, they may want to delegate the approvals of changes to person A, the delegation of Knowledge to Person B and the delegation of Orders to Person C

At the moment we would give Persons A, B and C approval delegation and hope they realise what they are approving before doing so..... hmmmmmm

I have in the past done work and split the various task types so that notifications were sent to the right people and items visible on dashboards, but the requirement for approvals was never there.   At the current client I may need to look at this for the approval side.

Any ideas / assistance or considerations are appreciated if anyone else has done this.

Cheers

8 REPLIES 8

Thank you so much for the help Laurent. It is more usefull to me 🙂


Hi Laurent, I wonder if you're able to help me with somewhat similar requirement:



Scenario:


We have set up a new field called delegate type in the Delegate table. Also, in the approval table, we have added same field so delegates should only see approval records if delegate type in delegate table is equal to the delegate type in approval table.




This is what I have so far in the My Approvals menu:


find_real_file.png



In the list view it is showing Approver2's 'Type2' also as the getDelegateType function is returning (Type1,Type2).



Code:


function getDelegateType(){


var u = gs.getUserID();


var answer = new Array();


var i = 0;


var delType;


// answer[i++] = new String();


var g = new GlideRecord("sys_user_delegate");


g.addQuery("delegate", u);


g.addQuery("approvals", "true");


g.addQuery("starts", "<=", gs.daysAgo(0));


g.addQuery("ends", ">=", gs.daysAgo(0));


g.query();



while( g.next())


answer[i++] = new String(g.u_delegate_type);


gs.log('delanswer=' + answer);


// gs.log('current delegate=' + current.u_delegate_type)



return answer;


}




I'm not sure how to update the code such that, James (delegate) should only see approval records that are highlighted. How do I accomplish this? Thanks in advance.


find_real_file.png


Hi Regina,



First let's start with your filter that needs to be modified.



For the specific use case the filter should looks like:



Approver is(dynamic): Me


AND State is: Requested



OR



Approver is: Approvers of type 1


AND Delegate type is: 1


AND State is: Requested



OR



Approver is: Approvers of type 2


AND Delegate type is: 2


AND State is: Requested



This means you would have a different javascript function call for each Delegate type (probably the same function with different parameters). However this has the inconvenient of displaying a big filter for your users. For reports that filter is not displayed so it is less of a problem.



So your function getMyDelegateTypes would not be used. Instead you would have something like:



Approver is: javascript: getMyApprovalsFromType('type1')


function getMyApprovalsFromType(type) {


  var u = gs.getUserID();


  var answer = new Array();


  var i = 0;


  answer[i++] = new String(u);


  var g = new GlideRecord("sys_user_delegate");


  g.addQuery("delegate", u);


  g.addQuery("approvals", "true");


  g.addQuery("u_delegate_type", type); //added line


  g.addQuery("starts", "<=", gs.daysAgo(0));


  g.addQuery("ends", ">=", gs.daysAgo(0));


  g.query();


  while( g.next())


  answer[i++] = new String(g.user);



  return answer;


}



I'm currently thinking on how to make the filter smaller for users that don't have delegates for a specific type. I tought of a processor to create the filter on the page however if someone save it's filter it won't be valid at a later time.


Thanks Laurent. I have now changed my strategy as my condition became complex and can no longer be met by using the condition builder. I have now created a script include to build the condition and call via a menu (URL from arguments). Thanks for the help!