Business rule not working on syslog (Logs) table

dhony
Tera Contributor

Hi ,

I want to write   a business rule on syslog table , Actually requirement is capture backgroundscript   related logs and move them into new custom table.

i created business rule setting filter condtion it is working when log created manually   but it is not working when logs created by system.See below screen shots

Capture1.PNG

Capture2.PNG

Chuck Tomasi's Blog

1 ACCEPTED SOLUTION

saikrishnayanam
Kilo Expert

Direct Business rules not triggered for Logs.

Use Scheduled jobs to get log records instead of Businessrules.

View solution in original post

14 REPLIES 14

My requirement is save Logs records from syslog table like below shown type logs(Source == 'Scriptbackgroundcheck'   logs) bg check record.PNG


Hi dhony



Here goes an alternative.



Create a daily scheduled job that pulls the list of the logs from the last day and filters those by "Scriptbackgroundcheck" and then take the appropriate action according to your need/requirement (notify a group, push these to an external service, create a defect for the development team, etc...).



Thanks,


Berny


For instance, your scheduled job code could look something like the following:



var grLog = new GlideRecord('syslog');


grLog.addEncodedQuery('sys_created_onONToday@javascript:gs.beginningOfToday()@javascript:gs.endOfToday()^source=ScriptBackgroundCheck');


grLog.query();


while (grLog.next()){


  // do something



  // here goes the action you want to do with those records


  // for test... lets just do a print of the message


  gs.print(grLog.message);


}



Thanks,


Berny


I hope the above makes sense and helps!


saikrishnayanam
Kilo Expert

Direct Business rules not triggered for Logs.

Use Scheduled jobs to get log records instead of Businessrules.