Send notifications of all assigned group of the sctask after submission of the request

Samiksha2
Mega Sage

Hi All,
I have created a Termination form. (Termination variable- Date/Time type).

After form submitted, a approval will send to manager and after approval, 27 catalog tasks will create. (Added in the flow).

Requirement is:

"Starting 2 hours after the Termination Date and Time, For each Task which is still open, Notify all members of the groups which have not completed their tickets".

 

I was trying to create scheduled jobs but I am stuck how to add script to check for every 2 hours.

 

 Please help me here.

 

Thanks,
Sam

20 REPLIES 20

Community Alums
Not applicable

Hi @Samiksha2 

Have you tried by adding a 'IF' condition to validate all Task STATE = <Task STATE> say State = Open || In Progress then send notification to the opened task assignment group members? OR you can create record action to generate an event or send notification action. Check below references that will surely help you.


Below are 3 ways to send a notification that @Uncle Rob  has explained very nicely, check this out, it will help in this case. 3 Ways to Notify with Flow Designer 

 

Send notifications from Flow Designer

 

1) Send Email action

2) Create Record action to generate an event (or custom Flow Action that does exactly that)

3) Send Notification action 

 

Additional resources, check SN docs to learn more on How to Send Notification action 

Viraj Hudlikar
Tera Sage

Hello @Samiksha2 

A script include to carry out our all logic as needed:

var NotifyOpenTasks = Class.create();
NotifyOpenTasks.prototype = {
    initialize: function() {},

    checkAndNotify: function() {
        var now = new GlideDateTime();

        var ritmGr = new GlideRecord('sc_req_item');
        ritmGr.addQuery('state', '!=', '3'); // Assuming '3' is the closed state
        ritmGr.query();
        while (ritmGr.next()) {
            var terminationDateTime = ritmGr.variables.termination_date_time; // Replace with the actual variable name
            if (terminationDateTime) {
                var terminationDateTimeObj = new GlideDateTime(terminationDateTime);
                terminationDateTimeObj.addHoursUTC(2);
                if (now >= terminationDateTimeObj) {
                    this.notifyOpenTasks(ritmGr.sys_id);
                }
            }
        }
    },

    notifyOpenTasks: function(ritmSysId) {
        var gr = new GlideRecord('sc_task');
        gr.addQuery('request_item', ritmSysId);
        gr.addQuery('state', '!=', '3'); // Assuming '3' is the closed state
        gr.query();
        while (gr.next()) {
            var groupId = gr.assignment_group;
            var groupEmail = gr.assignment_group.email;
            if (groupId && groupEmail) {
                this.notifyGroupMembers(groupId, gr);
            }
        }
    },

    notifyGroupMembers: function(groupId, taskRecord) {
                gs.eventQueue('task.open.notification', taskRecord, taskRecord.number);
        }
    },
    type: 'NotifyOpenTasks'
};

A email notification on sc_task table only triggered when event is fired event name "task.open.notification" in that email you can put your own content as required and in who will receive select Assignment Group field.

This all above configuration will help you to send email to group who has not completed task if termination date/time is 2 hrs from current date/time. 

 

If my response has helped you hit helpful button and if your concern is solved do mark my response as correct.

 

Thanks & Regards
Viraj Hudlikar.

Hello @Samiksha2 

 

Thank you for marking my response as helpful! 😊

I hope your concern has been fully addressed. If it resolves your issue, please consider marking it as the accepted solution. This will ensure others in the community can benefit from the solution too.

Thanks & Regards
Viraj Hudlikar.

Hi Viraj,

I tried both your script and  flow designer. But I am having time issue.

Samiksha2_1-1739435203583.png

I submitted the form at my local time, but it is showing different time not system time. because I check the current time zone of system its different(US/Central).

 

Thanks,
Sam