- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2025 05:16 AM
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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2025 05:59 AM
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.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2025 05:23 AM
function field is used during reporting to show data on the fly rather than storing in some field.
what's your requirement?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2025 05:44 AM
We had one custom table, in which there are two fields named as State and Published date..
If State is changed to Publish then I want to update Publish date using GlideDateTime..
and here I don't want to use Business rule/UI Policy., just want to check if there is any other possiblity that I could update it easily.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2025 05:48 AM
if not business rule then please use calculated field.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2025 05:45 AM - edited 02-14-2025 06:18 AM
HI @Sathwik1
The functional field does not store value in database instead use the calculated value .
here is my solution
(function calculatedFieldValue(current) {
if (current.u_resolved_date_time == "" && current.state == 6 ) { // Set resolved time if empty
answer = new GlideDateTime();
} else if (current.state == 2) { // 2 is 'In Progress', clear the field
answer = '';
} else {
answer = current.resolved_time; // Retain previous value otherwise
}
return answer; // return the calculated value
})(current);
If my response has helped you hit helpful button and if your concern is solved do mark my response as correct.
Thanks & Regards
Naga Chandan