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
mshinnmshinn 

Checkbox Validation

I am new to salesforce (using for 4 months now) and I need to add my first validation code.  I have not done this as of yet and I do not understand the coding language. 

I am looking for a code which will require an entry into another field on the same object when a different field is checked (it's a checkbox field).  I have two of these instances and would like the code rather simple.  For example:

If the Returned to Manufacturer (Field: Returnmfg; API name: Returnmfg_c) field is check, then I want to require the entry of a Return Authorization number in the additional custom field provided (Field: RMA; API name: RMA_c).  Also, when the Received back from Manufacturer field is checked, then I want to require a date entered into the custom field provided.

I've already created the fields.

Thank you!
HerosHeros
Try something like the following:

Number has to be filled in if checkbox is checked

AND( checkbox__c , ISNULL( Number__c ))
-this is saying that checkbox is checked then the number field cannot be blank.
mshinnmshinn
I entered the code, inputing my field names:

AND( Returnmfg__c , ISNULL( RMA__c))

and it said that there were no syntax errors, but it does not require me to fill in the field before saving.
Harry JamesHarry James

If RMA is a text field, then the expression ISNULL(RMA_c) will evaluate as false.  Text fields are never null.  Use the LEN function with a text field, as in:

AND( Returnmfg__c , LEN( RMA__c) = 0)

 

 

mshinnmshinn
Excellent!  Thank you so much!
World TechWorld Tech
Thanks for this information. I thought I would post back my validation rule as an example of a rule that needs to reference mulitple check boxes.  With this rule, If any of the listed check boxes are populated, then the specified text box must be populated.


AND ( OR(Cisco_Maintence__c, Cisco_Hardwar__c , General_Hardware__c, Other__c ) = TRUE , LEN( Discount_Percentage_Detials__c ) = 0)

Thanks for all the help.
Mahesh Babu Neeli 1Mahesh Babu Neeli 1

Hi All, 

I am new this salesforce technology, need a simple checkbox validation.

Fields like,
Is_Mandatory_c --- checkbox
First_Name_c --- text box

Now, i need a validation like:
When the user checked the Is_Mandatory check box, First_Name should be a mandatory field to fill.

So, could you please help me on this.