how to get the data from sysevent table to my custom table.

Suresh_32
Tera Expert

We want get data (insert/update records) from Event(sysevent) table to my custom table.

 

Created BR on table is 'sysevent' and after insert/update BR.

 

 var oldRecord = new GlideRecord("sysevent");
 oldRecord.addQuery('nameLIKElogin^ORnameLIKElogout'); // only we want login and Logout records from event table.
 oldRecord.query();
 while(oldRecord.next())
    var newRecord = new GlideRecord("u_newtable"); //my custom table
    newRecord.initialize();
    newRecord.u_created = current.sys_created_on;
    newRecord.u_name = current.name;
    newRecord.u_parm1 = current.parm1;
    newRecord.insert();
//    newRecord.update();
11 REPLIES 11

Hi @Ramesh_Naidu ,

 

As you suggested, updated BR but not trigged. (records are not getting from Event table to my custom table).

James Chun
Kilo Patron

Hi @Suresh_32,

 

My understanding is that you can't use a BR in the Event [sysevent] table - https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0750539

 

Instead, you can use a Script Action or run a Scheduled job to collect events from the table.

 

From your script, it appears that you want to collect the login/log out activities.

There is an OOB Indicator for collecting login activities which can be seen in the Security Centre application. 

JamesChun_0-1714685766295.png

 

Cheers