- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-28-2025 05:14 AM
Hi all,
I have a requirement where, when an SC Task is created in ServiceNow, I want the Due Date field to automatically populate 5 days after the creation date.
I want to know how to achieve this in two ways:
- Calendar Days: Simply add 5 days including weekends.
- Business Days Only: Add 5 working days (skip Saturdays and Sundays).
Questions:
How can I handle both scenarios in a script?
Thanks in advance for your help!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-28-2025 05:17 AM
you can use this script for 1st scenario to add 5 days
var nowTime = new GlideDateTime();
nowTime.addDaysUTC(5);
current.due_date = nowTime;
you can use schedule for 2nd scenario, check this link
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-28-2025 05:28 AM
You can use before insert Business rule on sc_task
Condition: current.request_item.cat_item.name == 'Your Item Name'
how are you creating the catalog task?
If you are using workflow then you can use advanced script in "Catalog Task activity" and script like this
If you are using flow then you can use inline f(x) script for this.
I believe I have answered your question and you can take it further from here.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-28-2025 05:39 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-28-2025 07:45 AM
is that a field or variable?
whatever it may be you can use that in your BR script and then have your logic
var fieldValue = current.request_item.fieldName;
var ritmRecord = current.request_item.getRefRecord();
var variableValue = ritmRecord.variables.variableName;
// now you have value and you can have your own logic
if (variableValue == 'Standard') {
var nowTime = new GlideDateTime();
nowTime.addDaysUTC(5);
current.due_date = nowTime;
} else {
// some other logic
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-28-2025 08:06 AM
I already shared the logic for above on how to access the variable value
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-28-2025 05:17 AM
you can use this script for 1st scenario to add 5 days
var nowTime = new GlideDateTime();
nowTime.addDaysUTC(5);
current.due_date = nowTime;
you can use schedule for 2nd scenario, check this link
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-28-2025 05:23 AM
@Ankur BawiskarIt's okay to use a Business Rule for the first scenario on the sc_task table, with the condition set to 'after insert or update', and scoped to a particular catalog item
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-28-2025 05:28 AM
You can use before insert Business rule on sc_task
Condition: current.request_item.cat_item.name == 'Your Item Name'
how are you creating the catalog task?
If you are using workflow then you can use advanced script in "Catalog Task activity" and script like this
If you are using flow then you can use inline f(x) script for this.
I believe I have answered your question and you can take it further from here.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-28-2025 05:39 AM
Thankss..