To set the due date of RITM and Catalog task to every Friday
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-09-2024 10:37 AM
Hi, can anyone please help me with the query, I need to set the due date of Requested Item and Catalog task to Friday .

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-09-2024 07:50 PM
@Ankitha4 you can create an on Insert before business rule on Requested Item and Catalog task table and keep the script as follows.
(function executeRule(current, previous /*null when async*/) {
// Get today's day (0 = Sunday, 1 = Monday, ..., 6 = Saturday)
var today = new GlideDateTime();
var dayOfWeek = today.getDayOfWeek();
// Calculate the days remaining to the upcoming Friday (Friday = 5)
var daysToFriday = 5 - dayOfWeek;
if (daysToFriday < 0) {
daysToFriday += 7; // If already past Friday, move to the next week
}
// Add the days to the current date
today.addDaysLocalTime(daysToFriday);
// Set the due date to the calculated Friday
current.due_date = today;
})(current, previous);
Hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-09-2024 10:25 PM
Thanks Sandeep for the reply . Can I use the same script in the client script of catalog item

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-09-2024 10:45 PM
@Ankitha4 The business rule I shared is a server side code. If you need to use this in the client script then you need to create a Client callable script include put the above script inside a script include function and call it from a catalog client script using GlideAjax.
Please mark the response helpful and accepted solution if it manages to answer your question.