Set DateTime field From Another DateTime Field and Add 15 Minutes
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2023 08:27 AM
Hello,
I'm trying to set a specific DateTime field using the sys_created_on field on a form. I have tried using a business rule but I cannot seem to get it to work.
How can I set a field to the sys_created_on field + 15 minutes after insert?
Open to any suggestions!
Thank you,
Derek
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2023 10:29 AM
HI There,
- Click on "New" to create a new Business Rule.
- Provide a meaningful name and a short description for the Business Rule.
- Set the "When to run" condition to "After" and choose "Insert" as the operation.
- In the "Advanced" section of the Business Rule form, write the following code in the "Script" field:
(function executeRule(current, previous) {
var timeToAdd = 15 * 60 * 1000; // 15 minutes in milliseconds
var createdOn = new GlideDateTime(current.sys_created_on);
var newDateTime = createdOn.getNumericValue() + timeToAdd;
current.target_datetime_field = new GlideDateTime(newDateTime);
})(current, previous);
Please mark the appropriate response as correct answer and helpful, This may help other community users to follow correct solution.
Regards,
Riya Verma
Regards,
Riya Verma