function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
TheresaAndersonTheresaAnderson 

Help please - I want to capture changes from a select list of check boxes.

The following code works but not the way I expected.   The problem is if the checkbox is true, the fomula continues to add 1 everytime the record is updated. 

 

IF(Sys_SA_6_1__c = True, 1,0) +
IF( Sys_SA_6_2__c = True, 1,0) +
IF( Sys_SA_6_3__c = True, 1,0) +
IF( Sys_SA_6_4__c = True, 1,0) / 4

 

What I would prefer to have is like the following.  But the PRIORVALUE is not allowed with a checkbox. 

 

( IF(PRIORVALUE(Sys_SA_6_1__c) = False, 1, 0) +

IF(PRIORVALUE(Sys_SA_6_1__c) = False, 1, 0) +

IF(PRIORVALUE(Sys_SA_6_1__c) = False, 1, 0) +

IF(PRIORVALUE(Sys_SA_6_1__c) = False, 1, 0) ) / 4

 

Does anyone have a suggestion on how to resolve?  Ultimately, I want a field (%) to determine how many checkboxes are true for the first time and divide by 4 to support the % (knowning that the checkbox could  be true at any given time).

Best Answer chosen by Admin (Salesforce Developers) 
thomastthomast

ISCHANGED() works on checkboxes, so try replacing each of your IFs with:

IF(AND(ISCHANGED(Sys_SA_6_1__c),Sys_SA_6_1__c),1,0)

 

If the checkbox has changed, and is now true, add 1. Checkboxes are inherently true or false, so you don't need to explicitly test them against the value (ie, Sys_SA_6_1__c = true).

 

-tt

All Answers

Steve :-/Steve :-/

How are you trying to do this?  Are you using a straight Formula Field?  If you are on EE or UE you might want to try using a Workflow Rule with a Field Update instead.

TheresaAndersonTheresaAnderson

The formula is in a Workflow rule. 

Steve :-/Steve :-/

Ahhh!  When is the WFR being triggered?  It might  be getting triggered every time the record is edited, try switching it to 

"When a record is created, or when a record is edited and did not previously meet the rule criteria"  

thomastthomast

ISCHANGED() works on checkboxes, so try replacing each of your IFs with:

IF(AND(ISCHANGED(Sys_SA_6_1__c),Sys_SA_6_1__c),1,0)

 

If the checkbox has changed, and is now true, add 1. Checkboxes are inherently true or false, so you don't need to explicitly test them against the value (ie, Sys_SA_6_1__c = true).

 

-tt

This was selected as the best answer