- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-30-2016 10:20 PM
Do I have to check "glide.schedules.repeat_nth" property and set it to Day??
I also wrote this script:
var now = New DateTime();
var day = now.getDay();
gs.log("Day is :" + " " +day);
if( day == 3)
{
var rec1 = new GlideRecord("incident");
rec1.initialize();
rec1.applyTemplate("Test");
rec1.insert();
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-30-2016 11:08 PM
Hi Shreya,
Please find the script to be written in conditional, this should work -
function checkThirdTuesday(workDay){
var ordinals = ["", "1", "2", "3", "4", "5"];
var date = String(new Date());
var tokens = date.split(" ");
var floatNumber = ordinals[Math.ceil(tokens[2]/7)];
var weekDay = tokens[0];
if(floatNumber == "3" && weekDay == workDay)
result = true;
else
result = false;
return result;
}
checkThirdTuesday('Tue');
Hopefully it helps
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-04-2016 02:43 AM
The above script doesnt use any property, its a clean javascript code which will run in SN instance conditional box also.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-19-2016 12:08 AM
Hi ...
I have one more question..
When I run this script the Date() function always returns the date and time in PDT time zone.. Though I have set it to IST time zone.. Why it is running in that time zone??
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-03-2020 05:52 PM
Hi,
I Used the same script to schedule every month on 3rd Tuesday and with RUN - Daily 10 AM..
For testing purpose when I click on execute now no request is created am I missing something.
*There is no issue with the script creating request if I uncheck the conditional checkbox and click on execute now request is created.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-25-2016 08:32 AM
Srikanth i have a similar issue where I'm trying to program a template schedule. I want the template to auto ticket on the 17th day after the 2nd Tuesday of each month. Can you help me with the logic that would go in the conditional area? Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-26-2017 08:09 AM
I had to do something similar and I think momentJS is your friend here. See Accessing Moment.js on Server side scripting for how to get it in your environment.
var MaintananceSchedule = Class.create();
MaintananceSchedule.prototype = {
initialize: function() {
},
schedule: function(weekOfMonth,dayOfWeek){
var moment = MomentJS.moment();
var day = moment().day(moment().isoWeekday()).format("dddd");
var week = moment().week() - moment().startOf('month').week() + 1;
return (day == dayOfWeek && week == weekOfMonth);
},
type: 'MaintananceSchedule'
};
I created a script include where you pass the week of the month needed and the day that's needed to match. So, for instance:
new MaintananceSchedule().schedule('4','Thursday')
That's all you would need in the conditional.