Show state 'Waiting for Approval' and approver name for which It is pending in service portal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-29-2019 09:15 AM
hi
I already see that on RITM the state is visible as "Waiting for Approval"
but how do I add approvers for which it is pending ?
In which widget shall I do the modifications ?
Please help if anybody has implemented the same and has code template.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2019 05:30 AM
I created new widget using below code
but it shows me nothing in the approvals.
There exists the approver in the ticket.
Can anybody help what can be missing?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2019 08:12 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2021 04:39 AM
Building on Premer's idea, I tried this out for myself. I had a bit of trial and error to get through but I got it working to populate the data on the Item field.
I created a custom field on the requested_item table called "u_waiting_approval_from" as instructed by Premer. This is a simple string field, but I bumped up the characters allowed to 80 in the dictionary. This will allow me to show multiple approver names on a single line. 40 wasn't enough, the names were getting cut out.
I then created a business rule on the sysapproval_approver table as instructed by Premer.
When to run: "After" Insert & Update.
No Conditions, No Actions.
Advanced:
(function executeRule(current, previous /*null when async*/) {
var docID = current.sysapproval; //works better with manual approver adds
var names = "";
var approvals = new GlideRecord('sysapproval_approver'); //setup query on the approval table
approvals.addQuery('sysapproval', docID); //filter all approvals that have matching sysapproval values
approvals.addQuery('state', 'Requested'); //filter those for a requested state
approvals.query(); //run the query
while(approvals.next()) //loop through the results
{
names += approvals.approver.name + " "; //stack results into the variable
}
var itm = new GlideRecord('sc_req_item'); //setup query on requested items table
itm.addQuery('request', docID); //find all items that have a matching 'request' field to the 'sysapproval' value
itm.query(); //run the query
if(itm.hasNext()) //if results found
{
while(itm.next()) //loop through the results
{
itm.u_waiting_approval_from = ""; //clear previous entry
itm.u_waiting_approval_from = names; //add approver(s)
itm.update(); //update
} //end while
} //end if
})(current, previous);
To illustrate this I've included some photos.
Edit - It may be worth noting that my approvals are per the Request, not per item.