We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

display approved groups and rejected groups in notification

AJAYKUMAR G
Tera Contributor

One record went approval on particular state to some groups(like A,B,C and D)- in the group any one can approve
A- approved
B- approved
C-rejected
D-rejected

if any thing rejected found in the approval it went previous state
notification Sent 
"As rejected
Approved Groups
A
B
Rejected Groups
C
D
" first time it is working fine

same process
then again went approval on same state and same groups
A- Rejected
B-Approved
C- Approved
D- Approved
same notification triggered
But in notification 
approved groups both are coming(1st time apprvoed and 2 nd time apprvoed)


Rejected groups both are coming(1st time apprvoed and 2 nd time apprvoed)

I don't want that 
2 nd time what groups given that should be 
Please advise thank you.

var gr = new GlideRecord('sysapproval_approver');
        gr.addQuery('document_id', current.sys_id);
        gr.query();
       
        var approved = [];
        var rejected = [];
        while (gr.next()) {
            var groupName = gr.group.assignment_group.getDisplayValue();
            var status = gr.state.getDisplayValue();
            if (status == 'Approved') {
                approved.push(groupName);
            } else if (status == 'Rejected') {
                rejected.push(groupName);
            }
        }
        var message = "";
        message += "<b>Approved Groups:</b><br>";
        message += approved.length > 0 ? approved.join("<br>") : "None";
        message += "<br><br>";

        message += "<b>Rejected Groups:</b><br>";
        message += rejected.length > 0 ? rejected.join("<br>") : "None";
        message += "<br><br>";

        template.print(message);

    })();




0 REPLIES 0