Hi all

basha shaik
Tera Contributor

scheduled job first monday of every year condition servicenow

1 REPLY 1

Pradeep Thipani
Mega Sage

Hi @basha shaik ,

 

Hope below sample script helps you

 

var now = new GlideDateTime();
var dayOfWeek = now.getDayOfWeekLocalTime(); // 1=Monday, 2=Tuesday, ..., 7=Sunday
var dayOfYear = now.getDayOfYearLocalTime(); // Day of the year (1-365 or 1-366 for leap years)

// Check if it's the first Monday of the year
if (dayOfWeek == 1 && dayOfYear <= 7) {
    // Your job logic here
}

 

 

Reference: https://www.servicenow.com/community/developer-forum/trying-to-run-a-scheduled-job-every-monday-tues...

https://www.servicenow.com/community/developer-forum/trigger-scheduled-job-every-month-second-week-m...

 

Thanks,

Pradeep

"If this response was useful, please select 'Accept as Solution' and mark it as 'Helpful.' This helps me provide better answers and assists the community ".

Regards,
Pradeep