Task "Schedule"

mail@pastecode.io avatar
unknown
javascript
2 months ago
999 B
4
Indexable
Never
var release = new GlideRecord('rm_release_scrum');
release.initialize();

var currentDate = new GlideDateTime();
var currentDayOfWeek = currentDate.getDayOfWeekUTC();
var daysUntilFriday = 5 - currentDayOfWeek;
currentDate.addDaysUTC(daysUntilFriday);

var date = currentDate.getDate();
// different timezone
var startDate = new GlideDateTime(date + " 20:00:00");
var endDate = new GlideDateTime(date + " 22:00:00");

release.start_date = startDate;
release.end_date = endDate;
release.short_description = "ServiceNow Weekly Release + Friday's date of the current week.";

var rlId = release.insert();
//==================================================

// Add a related record in m2m_product_release
var productRelease = new GlideRecord('m2m_product_release');
productRelease.initialize();
// id of ServiceNow PRD = '3a9d730997342510179537f11153afbd';
productRelease.model = '3a9d730997342510179537f11153afbd';
productRelease.release = rlId;
productRelease.insert();
Leave a Comment