How to calculate incident state changes count

Suraj biswal
Tera Contributor

We have an integer field called 'In progress' in the incident form. Every time an incident record is placed In progress state, the integer field needs to be updated by +1.

 

Any suggestion on it?

1 ACCEPTED SOLUTION

Omkar Kumbhar
Mega Sage
Mega Sage

Hello @Suraj biswal 

you should do this using before update business rule:

BR Condition: when the state changes to In progress

Script:

current.integer_field_name = parseInt(current.integer_field_name) + 1;

 

Thank you,

Omkar

If I was able to help you with your case, please click the Thumb Icon and mark as Correct.

View solution in original post

2 REPLIES 2

Omkar Kumbhar
Mega Sage
Mega Sage

Hello @Suraj biswal 

you should do this using before update business rule:

BR Condition: when the state changes to In progress

Script:

current.integer_field_name = parseInt(current.integer_field_name) + 1;

 

Thank you,

Omkar

If I was able to help you with your case, please click the Thumb Icon and mark as Correct.

Anand Kumar P
Giga Patron
Giga Patron

Hi @Suraj biswal ,
You can write after insert or update business rule on incident table and condition state changes to In Progress and use below script

(function executeRule(current, previous) {
    if (current.state == '2' && previous.state != '2') {
        current.u_custom_in_progress_count = (current.u_custom_in_progress_count || 0) + 1;
    }
})(current, previous);

Please mark it as solution proposed and helpful if it serves your purpose .

Thanks,

Anand