Change Request Notification Configuration

Abhilasha G T
Tera Contributor

Hi Team,

I have a requirement like below,

 

Table: Change Request 

 

when to send > The 'Reset' UI action button is used

 

Note: The 'Reset' UI action button is a custom one, on the change form, when we click on this button, if the change state is in Review or in scheduled state, it will be reset to as new state.

 

Who will Receive > Members of Group Approval Groups on the Change, where the Group Approval is in the Approve State.

 

How to achieve who will Receive requirement.

 

Regards,

Abhilasha G T

 

 

6 REPLIES 6

Ankur Bawiskar
Tera Patron
Tera Patron

@Abhilasha G T 

so what did you configure and where are you stuck?

If stuck what debugging did you perform?

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

Hi Ankur,

 

Need a suggestion how to implement, am not able to do that.

 

Regards,

Abhilasha G T

@Abhilasha G T 

you want state to be updated and also email to be sent?

You can have event, notification on change_request table

you can use gs.eventQueue() to trigger the email

In Notification, use "Event parm1 contains Recipient" = True

UI Action Condition:

current.state.toString() == '2' || current.state.toString() == '0'

Script:

// 1. Find all group approvals for this change in the "approved" state
var approvedGroups = [];
var gaGR = new GlideRecord('sysapproval_group');
gaGR.addQuery('parent', current.sys_id); // Link to this Change Request
gaGR.addQuery('approval', 'approved'); // Use the correct value for "Approve" in your instance
gaGR.query();
while (gaGR.next()) {
    approvedGroups.push(gaGR.assignment_group.toString());
}

// 2. For each group, find all active members
var recipients = [];
if (approvedGroups.length > 0) {
    var gmGR = new GlideRecord('sys_user_grmember');
    gmGR.addQuery('group', 'IN', approvedGroups.join(','));
    gmGR.query();
    while (gmGR.next()) {
        var user = gmGR.user.getRefRecord();
        if (user.active) {
            recipients.push(user.sys_id.toString());
        }
    }
}

// Now 'recipients' contains the sys_ids of all users to notify
// You can use this array to send notifications, emails, etc.

gs.eventQueue('eventName', current, recipients.toString());

current.state = '-5';
current.update();

I hope you know how to configure event, notification etc.

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

@Abhilasha G T 

Hope you are doing good.

Did my reply answer your question?

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