Create an incident on every month first Monday by using schedule job script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2023 04:04 AM
Hello Experts,
My requirement is
On every month first Monday(not Day 1 because in this month first Monday is on 5th of this week) I need to create an incident manually . Instead of manual incident creation I am thinking to create a schedule job .
how to achieve this by script,
fields mentioned below
caller_id = ABc (reference field)
contact_type = Self (choice)
urgency = support (choice)
short_description = ABCD
Best regards,
Nani
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2023 04:35 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2023 07:28 AM
Hi @Nani18 ,
First Monday for this month has already over, so you can try same script for check it will work on the second Monday for every month for testing purpose by little change of the above script I mentioned.
Put below script in Condition section
function checkmonday() {
var gdt = new GlideDateTime();
var day = gdt.getDayOfWeek();
var result = false;
if (day == 1 && gdt.getDayOfMonth()>7 && gdt.getDayOfMonth() < 15 ){
result = true;
}
return result;
}
checkmonday();
Put below script for Run script field
Script for creating new incident
============================
var gr1 = new GlideRecord('incident');
gr1.initialize();
gr1.caller_id = 'xxxxx' // put sys_id
gr1.contact_type = 'Self';
gr1.urgency = '2';
gr1.short_description = 'ABCD'
gr1.insert();
Regards,
Vinay T K.
Please mark this as helpful and correct answer, if this helps you