How to trigger a scheduled job for every 30 mins

JMR2
Mega Expert

Good day All,

I would like to get a notification when the Duplicate Algo administration remains switched off for more than 1 hour.

The notification should be sent to all the users having the 'Duplicate Algo Administration'.

 automatic notification after 1 hour and if the algo remains off, again a notification every 30 minutes until its switched on again.

Support team should get this notification

find_real_file.png

when ever the unchecked  the check box and then automatically trigger the notification for every 30mins up to when we click the check box again(means check box is not empty)

find_real_file.png

Please help me on above requirement. Thanks in-advance.

1 ACCEPTED SOLUTION

Hi Akash, Good morning 

Thanks for your information regarding on my task. process wise OK. But I'm tried below code. NOW it's working fine

var r=new GlideRecord('sys_properties');
r.addQuery('name','Value');

r.addQuery('name','Value');
r.addQuery('value','false');
r.query();
if(r.next())
{
var u=new GlideDateTime(r.sys_updated_on);
var t=new GlideDateTime();
var d=gs.dateDiff(u,t,false);
if(d>='01:00:00'){
var pop= gs.getProperty('sys_property name');

if (pop == 'false'){
var r=new GlideRecord('sys_user');
r.query();
if(r.next())
{
gs.log('New User');
gs.eventQueue('notify_user',r,gs.getUserID(),gs.getUserName() );
}
}
}
}

Regards,

Reddy

View solution in original post

6 REPLIES 6

That will stop it from firing early, but then it could fire late.

Example:

1:01 PM - System property deactivated
1:30 PM - Scheduled job runs - hour not passed
2:00 PM - Scheduled job runs - hour not passed
2:01 PM - Hour has passed, but no scheduled job to run
2:30 PM - Scheduled job runs - an hour passed
2:31 PM - Email sent

As you can see, the email will get sent an hour and a half after the property was set.

The scheduled job needs to run every minute.

You then need to check for the one hour, then every 30 minutes after.
It is messy - alas why I suggested workflows.

 

 

 


ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022

Hi Akash, Good morning 

Thanks for your information regarding on my task. process wise OK. But I'm tried below code. NOW it's working fine

var r=new GlideRecord('sys_properties');
r.addQuery('name','Value');

r.addQuery('name','Value');
r.addQuery('value','false');
r.query();
if(r.next())
{
var u=new GlideDateTime(r.sys_updated_on);
var t=new GlideDateTime();
var d=gs.dateDiff(u,t,false);
if(d>='01:00:00'){
var pop= gs.getProperty('sys_property name');

if (pop == 'false'){
var r=new GlideRecord('sys_user');
r.query();
if(r.next())
{
gs.log('New User');
gs.eventQueue('notify_user',r,gs.getUserID(),gs.getUserName() );
}
}
}
}

Regards,

Reddy