Hi event state is showing error.

ganeshexpert
Kilo Contributor

Hi,

 

I have create a scheduled script which will trigger event and hence Notification will send.

 

Below is the script:

var ProjectStatus = new GlideRecord('u_project_status');//Here u_project status is a Custom table

ProjectStatus.addEncodedQuery('str_sys_created_onONToday@javascript:gs.daysAgoStart(0)@javascript:gs.daysAgoEnd(0)');

ProjectStatus.query();

if(ProjectStatus.next())

{

    gs.eventQueue('project_status_report',ProjectStatus, null, null);//project_status_report is on the same table

}

 

Events get triggered but after processing showing state Error.

 

 

Thanks,

Ganesh

6 REPLIES 6

domaners
Kilo Guru

I was always under the impression that you had to pass a value back on the last two parameters, rather than null. Try passing back an arbitrary value like "a" or something and see if that helps:



gs.eventQueue('project_status_report',ProjectStatus, "a", "a");




Let me know if that helps, Adam.


If you have the error from the event log that would probably help.   Also, i'm not sure if ProjectStatus in the second parameter is really an object yet there.   Try this and see if if changes anything:



var ProjectStatus = new GlideRecord('u_project_status');//Here u_project status is a Custom table


ProjectStatus.addEncodedQuery('str_sys_created_onONToday@javascript:gs.daysAgoStart(0)@javascript:gs.daysAgoEnd(0)');


ProjectStatus.query();


if(ProjectStatus.next())


{


    ProjectStatus.next();


    gs.eventQueue('project_status_report',ProjectStatus, null, null);//project_status_report is on the same table


}


Having the second ProjectStatus.next() would make the loop skip ahead 2 records at a time.   "next()" moves to the next record in the GlideRecord set and returns true if it was able to, and false if not.


Actually, passing nulls is fine - they actually get translated to the string "null" in the event.   You can even pass null for the record.   I have a Scheduled Script that runs "gs.eventQueue("u_incident.custom.report", null, null, null);" which ends up firing an email notification that is not based on any one particular record.