- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-09-2018 01:29 AM
I want to run a report periodically every 30 mins to alert me of an issue - However I don't want it to run when I am not around. So just Monday to Friday - 9:00-18:00.
So I tried to strip the hour from the time and then use this - but it does not work!! Using the code below the alert just fires every 30 mins.
(Note: I have seen other types of solution using the (System Scheduler > Schedules) I don't have access to this)
function answerf(){
//Return 'true' to run the job
var answer = false;
//Get the day of week. 1=Monday, 7=Sunday
var now = new GlideDateTime();
//Get the time and strip out the current hour
var gdt = new GlideDateTime ();
gdt = gt.getByFormat('hh:mm:ss');
var gdtsplit = gdt.getDisplayValue().split(' ')[1].split(':');
var hour = gdtsplit[0];
//Run only on weekdays and during working office hours
if((hour > 09 && hour < 18)&&(now.getDayOfWeek() < 6)){
answer = true;
}
return answer;
}
answerf();
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-27-2018 12:12 PM
BR = Business Rule. They can run before/async/after a record is inserted, updated, queried, or deleted. The event queue is what you can add an event to which will run background events.
If you add the event to your event queue that an email needs to be sent out, the specified event should be associated with an email. For example, I would create an event with a unique name. I would then create an email notification and tell it to fire when the event is added to the queue. At that point, you would have to write in your Business Rule that you would like to add that event to the queue, when something specific happens on the table the Business Rule is watching.
Here is some documentation that should help clarify anything I might have missed:
You stated this should only run when there is an issue. Would this refer to the priority of an INC record? A BR can be catered to run, depending on provided conditions, if there are any (this will reduce the amount of times the rule will have to run on each record for that table). Then you could add the GlideSchedule check of creating a new schedule object with a predefined schedule, and validating that it '.isInSchedule()'.
I believe this is the correct approach for this problem and addresses all aspects of your question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-09-2018 09:47 AM
Are you expecting something to go wrong every 30 minutes? What record are you looking for when getting alerted about an issue? You can write a BR that looks for a specific ticket priority level and if it meets that condition, add an event to the event queue that will fire an email off to you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-14-2018 12:42 AM
Because our business reporting has to be very accurate its just reports/alerts that email me if people have not filled out fields on a incident/case
What is a "BR" ??
Not sure if I have access to the "event queue"?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-27-2018 12:12 PM
BR = Business Rule. They can run before/async/after a record is inserted, updated, queried, or deleted. The event queue is what you can add an event to which will run background events.
If you add the event to your event queue that an email needs to be sent out, the specified event should be associated with an email. For example, I would create an event with a unique name. I would then create an email notification and tell it to fire when the event is added to the queue. At that point, you would have to write in your Business Rule that you would like to add that event to the queue, when something specific happens on the table the Business Rule is watching.
Here is some documentation that should help clarify anything I might have missed:
You stated this should only run when there is an issue. Would this refer to the priority of an INC record? A BR can be catered to run, depending on provided conditions, if there are any (this will reduce the amount of times the rule will have to run on each record for that table). Then you could add the GlideSchedule check of creating a new schedule object with a predefined schedule, and validating that it '.isInSchedule()'.
I believe this is the correct approach for this problem and addresses all aspects of your question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-14-2018 01:15 AM
You can use Glideschedule to check whether the current date and time is in the schedule and proceed with your logic.
You have to create a new schedule if the mentioned timing and schedule is not available in our system.
https://community.servicenow.com/community?id=community_question&sys_id=0f3247addb98dbc01dcaf3231f96191f
https://community.servicenow.com/community?id=community_question&sys_id=79215be9dbdcdbc01dcaf3231f9619e1