Pending approval or approval group details in RITM worknotes activity

Keerti2
Mega Expert

Hello All,

May i know the BR code to get the pending approval details in RITM  worknotes activity ?

I have this requirements for all catalog workflow approvals , few of approvals for manager and few of them group approval  which are from sysapproval_approver table.

kindly help.

 

1 ACCEPTED SOLUTION

The answer has still already been given - 2 business rules.

View solution in original post

9 REPLIES 9

Brad Bowman
Kilo Patron
Kilo Patron

This will get you started, then you can tweak it to fit your requirements.  I suggest a Business Rule running After Insert and Update on the sysapproval_approver table, with the Filter Conditions State is Requested AND Approval for.Task type is Requested Item

find_real_file.png

Here is a sample Script for the Advanced tab

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

    var ritm = new GlideRecord('sc_req_item');
    ritm.addQuery('sys_id', current.document_id);
    ritm.query();
    if(ritm.next()){
        ritm.work_notes = "Pending approval by " + current.approver.name + " .";
        ritm.update();
    }

})(current, previous);

The results for a Group approval, when the group contains these 2 members, or for a User approval going to these 2 users

find_real_file.png

Vandana4
Kilo Expert

Thank you for help , its giving similar result .

But when the approval for Group , its giving all group members results .

Example : if group contain 20 group memebers , 20 pending approvals appearing .

Request you please provide code for update "Group Name" instead of group members.

 

Its fine for if pending single user , facing an issue for pending group .

Thank you

Hi Vandana,

if you require Group Approval information you would require BR on Group Approval table

BR: Table -> Group Approval [sysapproval_group]

Condition: Approval is Requested && Task Type is Group Approval && Parent.Number Startswith RITM

Script:

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

    var ritm = new GlideRecord('sc_req_item');
    ritm.addQuery('sys_id', current.parent);
    ritm.query();
    if(ritm.next()){
        ritm.work_notes = "Pending approval by " + current.assignment_group.getDisplayValue() + " .";
        ritm.update();
    }

})(current, previous);

find_real_file.png

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

I have a similar Business Rule to run on the sysapproval_group table

find_real_file.png

With this script

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

var ritm = new GlideRecord('sc_req_item');
ritm.addQuery('sys_id', current.parent);
ritm.query();
if(ritm.next()){
ritm.work_notes = "Pending approval by the " + current.assignment_group.name + " group.";
ritm.update();
}

})(current, previous);

You'll want to add a Filter Condition to the Business Rule running on sysapproval_approver to exclude these User approvals that are created when a Group approval is created.

find_real_file.png