count the total updates in INC

tanz
Tera Expert

I want to count the total updates made in an Incident record in the particular assignment group when the state is OnHold and store the count value in the field u_update_assigned_group. 

For example: INC01 in Assignment group MNC which is on State OnHold and updated twice should show a count 2. 

Please can you help me to achieve the script and what should I use(BR or client script) for the logic.

 

 

4 REPLIES 4

Martin Ivanov
Giga Sage
Giga Sage

This is your business rule.:

 

Please note that the u_update_assigned_group field must be of type Integer and has a default value of 0;

Please Mark Correct AND Helpful. Thanks!

find_real_file.png

find_real_file.png


Please mark Correct and click the Thumb up if my answer helps you resolve your issue. Thanks!
Martin Ivanov
ServiceNow MVP 2023, 2024

The above is not working. I am not changing the assignment group. I want to count the updates in the assignment group when state is OnHold. However when the assignment group changes for the same Incident the counter should freeze and during the next update in OnHold under new assignment group it will start again from 1.

Martin Ivanov
Giga Sage
Giga Sage

Hi. If your issue is resolved and my response has helped, plese consider marking Correct and Helpful. Thanks!

Martin Ivanov

2022 Community Rising Star

 


Please mark Correct and click the Thumb up if my answer helps you resolve your issue. Thanks!
Martin Ivanov
ServiceNow MVP 2023, 2024

Dayini
Tera Contributor

Hi Tanz,

 

You can achieve this using a before BR with state = 'On hold' condition and the script below : 

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

    // Add your code here
    if(current.assignment_group != previous.assignment_group)
    current.u_update_assigned_group = 0;
    else
    current.u_update_assigned_group +=1;

})(current, previous);
 
whenever there's a change in assignment group the counter value sets to 0.
 
If your issue is resolved and my response has helped, please consider marking Correct and Helpful. Thanks in advance!