How to insert the value in "Approval For" field of the sn_vul_change_approval source table

Swati_Jindal
Tera Contributor

I need the value in Approval For field because i have to send notification to the assignment group for Vulnerable Item & Remediation Task requested, approved & reject for Exception request.

Swati_Jindal_0-1744301545799.png

 

1 ACCEPTED SOLUTION

@Swati_Jindal 

you cannot set recipient using email script, only set CC and BCC

Is it the OOTB approval.inserted email which triggers

If yes then there you can add the logic in new notification and trigger it via event Queue on approval table

1) Ensure the OOTB "approval.inserted" notification doesn't trigger for your source table

AnkurBawiskar_0-1744350661479.png

 

2) Ensure the new notification triggers only for your source table and then trigger this via your new business rule on sysapproval_approver and specify your new event name

 

AnkurBawiskar_1-1744350702437.png

 

getRefRecord() -> won't work on document ID field
 

Something like this but please enhance as I am not aware of the table and fields

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

    // Add your code here
    var appr_Record = current.document_id;
    var gr = new GlideRecord("sn_vul_change_approval");
    gr.addQuery("sys_id", appr_Record);
    gr.query();
    if (gr.next()) {
        var arr = [];
        var vul_record = gr.vul_record.getRefRecord();
        var assignmentgroup = vul_record.assignment_group.sys_id;
        var groupMembers = new GlideRecord('sys_user_grmember');
        groupMembers.addQuery('group', group);
        groupMembers.query();
        while (groupMembers.next()) {
            arr.push(groupMembers.getValue('user'));
        }
        gs.eventQueue('eventName', current, arr.toString());
    }

})(current, previous);

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

View solution in original post

5 REPLIES 5

@Swati_Jindal 

Thank you for marking my response as helpful.

If my response helped please mark it correct and close the thread so that it benefits future readers.

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