Interested in a ServiceNow event built for developers? Registration for now[dev]26 is officially open!

How to track number of times a field is changed into the Activities section on a form?

Kiran_25
Tera Expert

Hi 

I'd like to track the number of times a field changes in the Activities section on a form. There is a 'Outcome' field that has been added to the form & I want the Activities notes to increment number of times that field has been changed. I am working with the Change Task table. 

 

I would also this number to be visible in a read only field that is displayed on the form.  What is the most straightforward (ie - beginner level 😊) way of achieving this? 

 

Thanks

1 ACCEPTED SOLUTION

@Kiran_25 

your business rule should be Before and not after

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

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

View solution in original post

7 REPLIES 7

Mark Manders
Tera Patron

What is the business case behind this? What is the expected result/improvement when you have this as a number on the form? 

You mention you are a beginner, so a tip: just because you can, doesn't mean you should. Always know the 'why' behind it. Do you need to report on this? If so: why? Why is it important? 

Look at the future: more and more people will ask you to track other fields as well and before you know it, you will be having a very slow performing instance, because of something that shouldn't be done.

 

The solution: create the field and just add 1 every time the field changes. You can use a flow or a business rule for this.

 

But if it's just the number you need, create a metric definition on change of this field. You can just report on the metric_result table for it.


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

Hi Mark 

There is a requirement for users working the task to track how many times the task Outcome has changed, this needs to be visible for tracking purposes. I know this can be achieved by creating a metric definition however users working on the form need visiblity of the number of times the field has changed. 

 

I have created a new Integer field and added it to the form and I have created a After Update business rule however this doesn't populate the field with anything so far :

(function executeRule(current, previous /*null when async*/) {

    if (current.u_outcome_result != previous.current.u_outcome_result) {
   
        current.u_outcome_result_count = (current.u_outcome_result_count || 0) + 1;
    }
})(current, previous);

@Kiran_25 

your business rule should be Before and not after

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

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

This is now working, thank you 😊