how to calculate reassignment count

keval3
Tera Contributor

Hi All,

please help me with below requirement.

In incident form I have created 2 fields 1st one is checkbox name with FCR and 2nd is string name with Reassignment count group. Now my requirement is that when incident ticket is assigned to me or 1st person and he did not reassign that ticket to some other person at that time checkbox should check and Reassignment count group automatically count as 0. and if I reassign the ticket to some other person at that time checkbox should un-check and 2nd field count should in-cress.please let me know how to do it.

 

Thanks & Regards

K

3 REPLIES 3

Ratnakar7
Mega Sage
Mega Sage

Hi @keval3 ,

 

You can achieve this requirement using a business rule on the Incident table. Here's one way to implement it:

  1. Create a new integer field on the Incident table called "Reassignment Count".

  2. Create a new business rule on the Incident table that runs when the record is updated. Set the "When to run" condition to "current.assignment_group.changes()" to ensure that the rule only runs when the assignment group is changed.

  3. In the business rule script, check if the "FCR" checkbox is checked. If it is, set the "Reassignment Count" field to 0 and exit the script.

  4. If the "FCR" checkbox is not checked, increment the "Reassignment Count" field by 1 and uncheck the "FCR" checkbox.

Here's some sample code to get you started:

 

(function executeRule(current, previous /*, g */) {

  // Check if the FCR checkbox is checked
  if (current.u_fcr) {
    current.u_reassignment_count = 0;
    return;
  }

  // Increment the Reassignment Count and uncheck the FCR checkbox
  current.u_reassignment_count = (previous.u_reassignment_count || 0) + 1;
  current.u_fcr = false;

})(current, previous /*, g */);

 

If my response was helpful in resolving the issue, please consider accepting it as a solution by clicking on the Accept solution button and giving it a thumbs up 👍. This will benefit others who may have a similar question in the future.

 

Thank you!

Ratnakar

 

keval3
Tera Contributor

Hi Ratnakar,

I have written below script but it is not working properly

(function executeRule(current, previous) {

 

if ((current.u_reassignment_count_assigned_to = 0) && (current.reassignment_count = 0)) {
(current.u_fcr = true); {
return;
}
current.u_reassignment_count_assigned_to = previous.u_reassignment_count_assigned_to || 0 + 1;
(current.u_fcr = false);

}
})(current, previous);

keval3_0-1680006620895.png

please let me know the solution.

 

Thanks & Regards

K

Hi @keval3 ,

Here's an updated version that should address these issues:

(function executeRule(current, previous) {

  // Check if the incident has not been reassigned before
  if (current.u_reassignment_count_assigned_to == 0 && current.reassignment_count == 0) {
    // Set the FCR checkbox to true
    current.u_fcr = true;
  } else {
    // Increment the reassignment count and set the FCR checkbox to false
    current.u_reassignment_count_assigned_to = (previous.u_reassignment_count_assigned_to || 0) + 1;
    current.u_fcr = false;
  }

})(current, previous);

 

Thanks,

Ratnakar