Show Delegate in Approves tab

alvatindra
Giga Contributor

Hi,

If I assign a delegate to an approver, Can I show delegate in Approvers tab in change request?

I made Fred luddy as delegate for Abel tuter.

In approvers tab, it shows only abel tuter, I need to show his delegate Fred luddy too.

find_real_file.png

1 ACCEPTED SOLUTION

Geoffrey2
ServiceNow Employee
ServiceNow Employee

You can pull that off using Hierarchical lists.



First, create a Relationship on the Approvals table that shows all the Delegates for the Approver.


Relationships are how you create your own custom Related Lists.



Screen Shot 2016-10-07 at 9.16.52 PM.png



Add the Relationship to the Approval table via Configure > Related Lists.


Screen Shot 2016-10-07 at 9.18.11 PM.png



Now go to the table where your Approvals Related List is - the Change Request table or whatever.


On the Approvals Related List, go to Configure > List Control and check Hierarchical lists.


Screen Shot 2016-10-07 at 9.22.02 PM.png


Screen Shot 2016-10-07 at 9.20.33 PM.png




You will see new arrows on each Row.   Expand the arrows.   The Hierarchical lists show all the Related Lists for that record - which is your new Delegates List.


Screen Shot 2016-10-07 at 9.14.22 PM.png


I personally think it looks ugly - but there is nothing you can do about that.


View solution in original post

5 REPLIES 5

Geoffrey2
ServiceNow Employee
ServiceNow Employee

There can be multiple Delegates for one person.   There is no out-of-the-box way to do what you need. So you need to create a new field and populate it.


To do this I would create a new User List field on the Approvals table (sysapproval_approver) called u_delegates, and populate it with a before insert Business Rule.



(function executeRule(current, previous /*null when async*/) {



  // Look for Delgates


  var userIDs = [];


  var del = new GlideRecord('sys_user_delegate');


  del.addQuery('user', current.approver);


  del.addQuery('approvals', true);


  del.addQuery('starts', '<=', gs.nowDateTime);


  del.addQuery('ends', '>=', gs.nowDateTime);


  del.query();


  while (del.next()) {


        userIDs.push(String(del.delegate));


  }


  current.u_delegates = userIDs.join();



})(current, previous);



Then you can add your Delegates field to the List View of your Approvals table.  


You might want to put a similar Business Rule on the Delegates table to update existing Approvals when a new Delegate is created after the Approval is Requested.


Hi Geoffrey Sage,


Thanks for the response!



I want to show delegate as a record along with the actual approver but   not as a field/column .



Ex:In the above screenshot, It should show fred luddy along with abel tuter (2 records) in approver tab.


When the delegate time interval gets finish, then the record of delegate should not get visible in approver tab.This is my actual requirement


Geoffrey2
ServiceNow Employee
ServiceNow Employee

You can pull that off using Hierarchical lists.



First, create a Relationship on the Approvals table that shows all the Delegates for the Approver.


Relationships are how you create your own custom Related Lists.



Screen Shot 2016-10-07 at 9.16.52 PM.png



Add the Relationship to the Approval table via Configure > Related Lists.


Screen Shot 2016-10-07 at 9.18.11 PM.png



Now go to the table where your Approvals Related List is - the Change Request table or whatever.


On the Approvals Related List, go to Configure > List Control and check Hierarchical lists.


Screen Shot 2016-10-07 at 9.22.02 PM.png


Screen Shot 2016-10-07 at 9.20.33 PM.png




You will see new arrows on each Row.   Expand the arrows.   The Hierarchical lists show all the Related Lists for that record - which is your new Delegates List.


Screen Shot 2016-10-07 at 9.14.22 PM.png


I personally think it looks ugly - but there is nothing you can do about that.


Hi Geoffrey Sage,



Thank you, I tried as you said, it worked.


It looks really weird, but anyway achieved the functionality.


Many thanks to you!!