I want to update a "Resolved Date" field on a table.

Sathwik1
Tera Expert

In a table "A" there are two fields., namely Field A, Field B.

 

Field A = State

Field B = Resolved Date

 

-> If STATE changes to "Resolved" then I need to update the RESOLVED DATE as current date/time.

 

I want to achieve it through "Function field" instead of using Business rule or UI Policy or something..

 

Can someone please help on this ? @Ankur Bawiskar 

1 ACCEPTED SOLUTION

@Sathwik1 

calculated field calculate every time a row is read.

So if you open incident list and it has 100 rows then the calculated field calculation will be performed 100 times.

I won't recommend doing this.

Since you just want to store then why not use before update business rule and store the current time in custom field.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

11 REPLIES 11

Will it work for existing records also?

@Sathwik1 

calculated field calculate every time a row is read.

So if you open incident list and it has 100 rows then the calculated field calculation will be performed 100 times.

I won't recommend doing this.

Since you just want to store then why not use before update business rule and store the current time in custom field.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Sathwik1 

Thank you for marking my response as helpful.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Can we use something like below in order not to execute at every time?

There are some other methods also exist in the BR, that's an after BR.. and that BR is calling OOB script include and there has some update operation.. so I don't want to touch OOB, and for this simple thing I don't want to use another new BR.

@Ankur Bawiskar 

 

 

(function calculatedFieldValue(current) {
var answer = '';
 if(current.resolved_time == '')
{
    if (current.state == 6)    // 6 is the 'Resolved' state
{              
    answer = new GlideDateTime();
     return answer;
} 
else
 {
    return answer;
}
}
return answer;

})(current);

 

 

  

@Sathwik1 

calculated field is out of picture due to performance impact.

Why not use flow designer which can run on record update?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader