How to get the date when the field was updated first using a script ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-08-2018 09:56 AM
How to get value of date when the field was first updated using a script ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-08-2018 10:22 PM
Hi,
I assume you are looking to update a custom date field with current date when the record is updated.
If that case,
1. Create a before update business rule.
2. Set condition based on your requirement. For E.g. Custom Field is empty (to update the field only when it is empty)
3. Use the below script to populate the custom field value
Script:
*************
var date = '';
var dateObj = new GlideDateTime();
date = dateObj.getDate();//returns date based on system time zone
//date = dateObj.getLocalDate();//returns date based on user's time zone
current.u_customfield_name = date;
**************
Note: Don't include current.update() in this Business Rule.
Mark Correct if this solves your issue. Hit Like/Helpful based on the impact.
Regards,
Udhay