How to get the date when the field was updated first using a script ?

Khushboo8
Tera Contributor

How to get value of date when the field was first updated using a script ?

1 REPLY 1

Kamal17
Kilo Sage

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