+ Start a Discussion
Diego MorenoDiego Moreno 

Validation rule formula question

Hello,

i am trying to create a formula that doesn't allow usesr to edit certain fields once a record is save with a checkbox clicked, so i need the formulla to depend on whether or not the check box is clicked.

this is what i've got so far: 

AND(PRIORVALUE( Is_approved__c ), TRUE, 
ISCHANGED( Is_approved__c )) ||  ISCHANGED( Gross_Pay__c ) ||  ISCHANGED( End_Date_del__c ) ||  ISCHANGED( Has_dental_vision_insurance__c ) ||  ISCHANGED( Has_Medical_Insurance__c ) ||  ISCHANGED( Start_Date__c ) ||  ISCHANGED( Name ) ||  ISCHANGED( Net_Pay__c )
Best Answer chosen by Diego Moreno
John PipkinJohn Pipkin
Diego, 

If I read your requirements correct (These fields cannot be changed if Is_Approved__c is checked) then the formula should be :
 
AND(
	Is_approved__c,  
	OR(  
	ISCHANGED( Gross_Pay__c ) ,
	ISCHANGED( End_Date_del__c ) ,
	ISCHANGED( Has_dental_vision_insurance__c ),
	ISCHANGED( Has_Medical_Insurance__c ) ,
	ISCHANGED( Start_Date__c ),
	ISCHANGED( Name ) ,
	ISCHANGED( Net_Pay__c )
	)
)

ISCHANGED() formula only evaluates to true on update, not insert. 

If the checkbox should be false to enforce this then it should read:
 
AND(
	NOT(Is_approved__c),  
	OR(  
	ISCHANGED( Gross_Pay__c ) ,
	ISCHANGED( End_Date_del__c ) ,
	ISCHANGED( Has_dental_vision_insurance__c ),
	ISCHANGED( Has_Medical_Insurance__c ) ,
	ISCHANGED( Start_Date__c ),
	ISCHANGED( Name ) ,
	ISCHANGED( Net_Pay__c )
	)
)



 

All Answers

John PipkinJohn Pipkin
Diego, 

If I read your requirements correct (These fields cannot be changed if Is_Approved__c is checked) then the formula should be :
 
AND(
	Is_approved__c,  
	OR(  
	ISCHANGED( Gross_Pay__c ) ,
	ISCHANGED( End_Date_del__c ) ,
	ISCHANGED( Has_dental_vision_insurance__c ),
	ISCHANGED( Has_Medical_Insurance__c ) ,
	ISCHANGED( Start_Date__c ),
	ISCHANGED( Name ) ,
	ISCHANGED( Net_Pay__c )
	)
)

ISCHANGED() formula only evaluates to true on update, not insert. 

If the checkbox should be false to enforce this then it should read:
 
AND(
	NOT(Is_approved__c),  
	OR(  
	ISCHANGED( Gross_Pay__c ) ,
	ISCHANGED( End_Date_del__c ) ,
	ISCHANGED( Has_dental_vision_insurance__c ),
	ISCHANGED( Has_Medical_Insurance__c ) ,
	ISCHANGED( Start_Date__c ),
	ISCHANGED( Name ) ,
	ISCHANGED( Net_Pay__c )
	)
)



 
This was selected as the best answer
Diego MorenoDiego Moreno
it worked! thanks a lot john!
John PipkinJohn Pipkin
No problem!