how to set a Future date as 1 Year plus based on a date item set.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2023 07:42 PM
I am wanting to have an End date for 1 year plus *based on a date*, set within a form.
e.g. Start date 1-1-2015 (set by users\ Customer)
End date (Start date+ 1 year, dynamically updating based on Start date value change

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2023 12:16 AM
@White Wolf Please refer to this thread https://www.servicenow.com/community/developer-forum/add-an-year-to-a-current-date-in-client-script/... similar implementation has been done by the author in this thread.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2023 12:24 AM
I have an simpler solution than that, that seems to use the created date. For my need I need to have an option for Date value X plus 1 year
i also need to have the validation re run automatically when the reference value is changed

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2023 04:34 AM
Hi White,
To set the End date dynamically in ServiceNow based on a Start date field value, you can create a business rule that runs when the Start date field changes. Here are the steps to create the business rule:
- Go to the "Business Rules" module in ServiceNow.
- Click "New".
- Enter a name for the business rule, such as "Calculate End Date".
- Set the "Table" to the table where your form is located (e.g. "Incident").
- Set the "When to run" field to "Before".
- Set the "When" field to "insert, update".
- Under "Advanced", set the "Script" field to the following JavaScript code:
(function executeRule(current, previous /*null when async*/) {
// Get the start date and calculate the end date
var startDate = current.start_date;
var endDate = new GlideDateTime(startDate);
endDate.addYears(1);
// Set the end date value on the current record
current.end_date = endDate.getDisplayValue();
})(current, previous);
Thanks,
Rahul Kumar
Thanks,
Rahul Kumar