How to configure the Inactivity notification for problem record

Research
Tera Guru

How to configure the Inactivity notification for problem record

I have created Inactivity event
and Notification on problem 
under who will receive - Assignment group of problem is working expected
I also want to send the same notification to the associated problem task analysts 

Thanks 

5 REPLIES 5

Ankur Bawiskar
Tera Patron
Tera Patron

@Research 

this article explains it well

How Inactivity Monitor works? 

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

Medi C
Giga Sage

Hi @Research,


Are you using an event based notification? if so:

  • Ensure "Event parm 1 contains recipient" is checked on your notification
  • Use the following script to gather the Problem task analyst:
var recipients = [];

    // Get all associated Problem Tasks
    var pt = new GlideRecord('problem_task');
    pt.addQuery('problem_id', grProblem.sys_id); //Use your Problem Sys ID
    pt.query();

    while (pt.next()) {
        if (pt.assigned_to) {
            recipients.push(pt.assigned_to.toString());
        }
    }

    gs.eventQueue('problem.inactivity', grProblem, recipients)​

 


If you found this helpful, please hit the thumbs-up button and mark as correct. That helps others find their solutions.

Research
Tera Guru

Hi @Medi C 
Some where I am missing step please guide me
when to send
Event is fired 

Research_0-1744437322428.png

I selected "Event parm 1 contains recipient"

Research_1-1744437384514.png

Email script

Research_2-1744437605559.png

No luck please guide me
Thanks

VIJAY YACHAM1
Tera Contributor

Hello @Research

 

Please try to implement below solution if it works:

 

Since "Who will receive" in the Notification doesn't directly let you reference related task users in a list, you can use a Notification Script to add them.

🔹 Steps:

  1. Open your Notification

    • Go to System Notification > Email > Notifications

    • Open the notification tied to your inactivity event on the Problem table.

  2. Scroll to the "Who will receive" section

    • Leave the Assignment group entry as-is.

    • Click New to add a new recipient type.

      • Type: Script

      • This lets you add recipients via Glide scripting.

  3. Add the script below to gather "Assigned to" users from all related Problem Tasks:

 

javascript
CopyEdit
(function execute(inputs, outputs) { var recipients = []; var taskGr = new GlideRecord('problem_task'); taskGr.addQuery('problem_id', current.sys_id); taskGr.addNotNullQuery('assigned_to'); taskGr.query(); while (taskGr.next()) { var user = taskGr.assigned_to; if (user && !recipients.includes(user.toString())) { recipients.push(user.toString()); } } outputs.recipients = recipients; })(inputs, outputs);
 
  • This script loops through all Problem Tasks linked to the current Problem, collects all unique assigned_to values, and adds them to the notification recipients.

  1. Save the notification


If this is useful, accept my solution and like which helps alot.