The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Worknotes related

Abdul
Tera Contributor

hi

 

When a user with username Nscintegprod.ser adds worknotes in Incident, i need to update the field u_acknowledged_date with the date and time when the user adds the comment how can we do that?

 

Thanks

2 REPLIES 2

vignesh parthib
Tera Contributor

Hi Abdul,

Create a Business Rule:

  • Table: incident
  • When: before (or after, depending on your needs; before is safer for field updates)
  • Update: true

Business Rule Conditions:

You can optionally set a condition like:

  • Work notes changes: current.work_notes.changes() == true


Script:
if (current.work_notes.changes()) {
// Check if the user is 'Nscintegprod.ser'
if (gs.getUserName() == 'Nscintegprod.ser') {
current.u_acknowledged_date = new GlideDateTime(); // sets to current date/time
}

 

Thank you,

Vignesh Parthiban

If you feel the solution is working, please mark it as accepted.

Nawal Singh
Tera Expert

Hi @Abdul ,

 

For this requirement you need to create Business rule-

 

Go to:-- System Definition → Business Rules → New

- Configuration:
- Field Value
- Name Set Acknowledged Date from Work Note
-Table incident
-When before
-Insert true (checked)
-Update true (checked)
-Advanced true (checked)
-Condition (leave blank or optional if needed)

 

and write down the script -

 

(function executeRule(current, previous /*null when async*/) {
    // Check if user is 'Nscintegprod.ser' AND work_notes field is updated
    if (gs.getUserName() === 'Nscintegprod.ser' && current.work_notes.changes()) {
        current.u_acknowledged_date = new GlideDateTime(); // Set current date/time
    }
})(current, previous);

 

if my response is helpful please mark as helpful and accept the solution

 

Thank you!!