Use PDIs? Take our 5-minute survey to help shape the PDI roadmap.

To Revert a Field to Its Original Value

raksh
Tera Contributor

Hi All

I have a requirement and would really appreciate any help or guidance.

The issue I am facing is with Scenario 2.
For example, if the original Case Type is Incident:
Assignment Group satisfies all 3 criteria → Case Type changes from Incident to Apple. The Assignment Group is later changed to a group that does not satisfy the 3 criteria. At this point, I want the Case Type to revert from Apple back to Incident but this not happening.
Since the original Case Type can be any choice, I cannot hardcode a specific Case Type.
___________________________________________________________________
I have a Business Rule where I am changing the Case Type based on 3 conditions in the Assignment Group.
BR Condition: Assignment Group changes

3 criteria:
1. Assignment Group has Field 1 (checkbox) = true
2. Assignment Group has Field 2 (List type field) containing Task
3. Assignment Group has Field 3 (Choice field) = Test

Scenario 1
When the Assignment Group satisfies all 3 criteria:
•  If Case Type ≠ Apple → change it to Apple.
•  If Case Type = Apple → leave it unchanged.


Scenario 2
When the Assignment Group does not satisfy all 3 criteria:
•  If Case Type = Apple → restore the Case Type that existed before it was changed to Apple.
•  If Case Type ≠ Apple → leave it unchanged.
•  The original Case Type can be any choice, not necessarily one specific value.

 

Code: 
(function executeRule(current, previous) {

var cond1 = current.field1 == true;

var field2 = current.assignment_group.field2.getDisplayValue();
var cond2 = field2.indexOf('Task') > -1;

var cond3 = current.assignment_group.field3 == 'Test';

// Scenario 1: All three conditions are satisfied
if (cond1 && cond2 && cond3) {

if (current.u_case_type != 'apple') {
current.u_case_type = 'apple';
}

// Scenario 2: Conditions are not satisfied
} else {

if (current.u_case_type == 'apple' && previous.u_case_type != 'apple') {
current.u_case_type = previous.u_case_type;
}
}

})(current, previous);

0 REPLIES 0