Due date on sc_task form should be one day prior to start date
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-29-2023 12:37 AM
Hello All,
We have an requirement ,where when user will enter the start date on form ( catalog item form ) then after submitting the form, the due date field on sc_task form should be one day prior to start date.
Any help would be appreciated.
Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-29-2023 12:47 AM
Hi @C_S3 ,
Use before update/insert business rule on the sc_task table and give specific condition when it needs to update.
Use below script on business rule
(function executeRule(current, previous /*null when async*/ ) {
var startdate = current.variables.start_date;
var dt = new GlideTime();
var time = dt.getDisplayValue().split(' ')[1];//get time
var finaldatetime = startdate + ' ' + time; //it will give start date and time
var gdt = new GlideDateTime(finaldatetime); //using finaldatetime to subtract 1 day from start date
gdt.addDays(-1); //substract 1 day
current.due_date = gdt;//update on due date field
})(current, previous);
Note: place your correct backend values in script
If this solution worked for you, please mark this as helpful & accept the solution as correct!
Regards,
Shyamkumar
Regards,
Shyamkumar

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-29-2023 01:17 AM
Hi @C_S3 ,
Are you looking for a logic to get start date from the catalog item variable and set 1 day prior (Start date entered) on the catalog task???
Can we know how are you creating the catalog task so that we can provide script to update.
to begin with to retrive the start date entered use -- varibaleobject.variables.start_date (ex: current.variables.start_date)
Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-29-2023 01:21 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-29-2023 02:26 AM - edited ‎08-29-2023 02:27 AM
Great
Use script to set due date as below :
var date = fd_data._1__get_catalog_variables.start_date; //get start date from the variable
var gdt = new GlideDateTime(date);
gdt.addDays(-1); // substract a day
gdt =gdt.toString();
return gdt;
Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025