- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2024 06:02 AM
I need to schedule a recurring task assigned to Zenpact Group
The task should be created once every three months, beginning the first Tuesday every January, April, July and October (or you can think of something better if it is more suitable to you).
How we achieved this for this time
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2024 03:57 AM
Set your scheduled job to run this script on a daily base. It will create the task only on the defined days.
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2024 06:40 AM
This script creates an incident, but I guess your question is more about how to get the timing of the trigger correctly:
(function executeRule(current, previous /*null when async*/) {
// Get current date
var currentDate = new GlideDateTime();
currentDate.setDayOfMonth(1); // Set day to the 1st of the month
// Check if it's January, April, July, or October
var month = currentDate.getMonth();
if (month == 0 || month == 3 || month == 6 || month == 9) {
// Check if it's the first Tuesday of the month
if (currentDate.getDayOfWeek() == 3) { // 3 corresponds to Tuesday
// Create incident here
var newIncident = new GlideRecord('incident');
newIncident.initialize(); // Initialize the record
// Set other incident fields as needed
newIncident.insert(); // Insert the record
}
}
})(current, previous);
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2024 01:09 AM
Hi Mark,
Where i will use this script , means i will use this script with scheduled jobs or individual or what condition i will use in business rule ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2024 03:57 AM
Set your scheduled job to run this script on a daily base. It will create the task only on the defined days.
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark