The CreatorCon Call for Content is officially open! Get started here.

Any one it could be possiable throught Events or scheduled job?

mastan babu ko1
Tera Contributor

Need to be able to troubleshoot unusual events. We have a situation where periodically consumable transaction are entered at an inhuman rate. We need to write a routine to detect this so we can alert SN support.

 

--->If there is more than 4 records that are modified at the same time then send a message that the issue is occuring.  So if we get 4 records or more on the same day, same hour, same minute, same second from the same userid then this meets the condition.

 

-->Then when this happens you send us an immedate message within 1 day of the issue so we can access the information on the logs.  So send email to our L2 group and we can notify.

4 REPLIES 4

shloke04
Kilo Patron

Hi @mastan babu ko1 ,

 

Not sure on what the ask is here. Can you explain your issue statement more clearly? 

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

mastanbabuk
Tera Contributor

If user made any modification more than 4 records on consumer table by same Userid(same person) in same day. If this condition meets, Then we need to send a email to Servicenow instance. In order to check in system logs when they need.

mastanbabuk
Tera Contributor

If user made any modifications more than 4 records on consumer table by same Userid(same person) in same day. If this condition meets, Then we need to send a email to Servicenow instance. In order to check in system logs when they need

Hi @mastanbabuk ,

Still your details are not elaborative, which makes it difficult to understand the ask and help out . Based on so fat what I have understood you want to trigger a notification when the same User updates more than 4 records in consumable table.

I would propose to make use of Scheduled Job here to meet this requirement.

 

Steps:

1. Create an event by navigating to Registry as shown below:

shloke04_4-1715153935939.png

 

 

2. Create a Scheduled Job and use the script shared below:

Please make adjustment as required as per your configurations:

var ga = new GlideAggregate('alm_consumable');
ga.addAggregate('COUNT');
ga.groupBy('sys_updated_by');
ga.addEncodedQuery("sys_updated_onON2024-05-08@javascript:gs.dateGenerate('2024-05-08','start')@javascript:gs.dateGenerate('2024-05-08','end')");
ga.query();

while (ga.next()){
 gs.print(ga.getDisplayValue('sys_updated_by') + '|' + ga.getAggregate('COUNT'));
}
if(ga.getAggregate('COUNT') >= 4){
	
	gs.eventQueue('Name of your Event',ga,Parm1, Parm2);
}

3. Configure your notification using this event used in Scheduled Job

 

 

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke