How to trigger notification, it contains multiple records?

prasanna7869
Mega Expert

Hi Team,

I have requirement on email notification.

Based on Requestor, we need to trigger notification for each quarter and should show multiple records. How can we achieve this requirement?

For example, when gliding the table with one "quarter" duration, the following records are displayed:

INC001234 - Requestor A

INC002345 - Requestor B

INC004567 - Requestor A

INC002367 - Requestor A

INC004523 - Requestor A

INC005678 - Requestor B

So, I want to send a notification to Requestor A like following way:

------------------------------------------------------

Hi Requestor A,

The following records for this Quarter:

INC001234

INC004567

INC002367

INC004523

Thanks,

Team

------------------------------------------------

Requestor B like following way:

------------------------------------------------------

Hi Requestor A,

The following records for this Quarter:

INC002345

INC005678

Thanks,

Team

------------------------------------------------

I tried the following way:

var gr = new GlideRecord('incident');

gr.addQuery('u_status','u_active');

gr.query();

if(gr.next()){

var creDate = gr.sys_created_on;

var expDate = gs.now();

var diff = gs.dateDiff(creDate,expDate,true);

                  if(diff>=7344000 && diff<=7776000)                               // I've taken 85 and 86 days records

                  {

                    gs.print(gr.u_number+ '- ' gr.u_requestor);

                  }

}

By this script, I'm getting out put like:

INC001234 - Requestor A

INC002345 - Requestor B

INC004567 - Requestor A

INC002367 - Requestor A

INC004523 - Requestor A

INC005678 - Requestor B

Now I need to send a notification to Requestors A & B. I know by using gs.eventQueue we can send notification. But, my query is how can we separate requestors records and how can we send the same.

Please suggest solution ASAP.

Thanks & Regards,

Prasanna Kumar

12 REPLIES 12

Hi chuck Tomasi,

 

i have write the scheduled jobs while executing once, it won't work. i am checked in the system log there it shows an warning like 

Warning:

org.mozilla.javascript.EcmaError: "caller_id" is not defined.
Caused by error in <refname> at line 1

==> 1: caller_id

 

i have write the following code,

var au = new ArrayUtil();
var list = [];
var inc = new GlideRecord('incident');
inc.addQuery('active', true);
inc.query();
while (inc.next()) {
list.push(inc.getValue("caller_id"));
}

var shortList = au.unique(list);

for (var i = 0; i < shortList.length; i++) {
gs.eventQueue("incident.requester.list",null,shortList[i],''); // trigger the event
}

 

 

Kindly, provide the correct solution.

 

Thanks,

Saravanan

 

Hi Chuck,

I was able to adapt this to my needs today.

Thank you!

Tim Belet

Hi Chuck,

I was able to adapt this to my needs today.

Thank you!

Tim Belet