0

I've added a custom checkbox field to the Case object (I called it Send_to_WebService__c). My problem however, is I need to include a few validation rules for this new checkbox:

  • If the checkbox has already been checked, it can never again be unchecked.
  • When marking this box as checked, an additional field (lets call it, SampleField_Case_Id__c), cannot be blank or null.

I can get the first criteria working correctly by entering the following error condition formula, but I'm not sure how to expand upon this formula to include the 2nd criteria:

AND(PRIORVALUE(Send_to_WebService__c), TRUE, ISCHANGED(Send_to_WebService__c))

The above basically says, if when hitting "Save", if the checkbox has already been checked, throw an error saying they can't uncheck it. I've tried expanding on this though, to include the 2nd criteria of ensuring SampleField_Case_Id__c isn't null or blank, but I keep getting syntax errors.

How can I expand upon that formula to include this 2nd criteria validation?

  • I've tried expanding on this though what have you tried for this? – JaredT Dec 13 '17 at 16:48
2

I think it's easier to read and understand if you change your initial condition to include PRIORVALUE(Send_to_WebService__c)=TRUE. While you certainly could combine the two conditions into one rule like so:

OR(
    //condition that second field cannot be blank
    AND(
        Send_to_WebService__c = TRUE,
        ISBLANK(SampleField_Case_Id__c)
    ),
    //condition that the checkbox cannot be unchecked
    AND(
        PRIORVALUE(Send_to_WebService__c)=TRUE,
        ISCHANGED(Send_to_WebService__c)
    )
)

it probably makes sense to create a separate validation rule for the condition that your second field should be populated if the checkbox is checked, because you'll want to display a different error message to the user.

| improve this answer | |
  • It's better to keep them as a separate validations - this would allow you to have a specific error message for each. @todd-sprinkel - you don't need to do True (or False) validations on Boolean fields - just use them as is, e.g. AND( Send_to_WebService__c, ISBLANK(SampleField_Case_Id__c) ) – o-lexi Dec 13 '17 at 17:32
  • Thank you Todd for both the answer to my question and the suggestion of splitting these into two conditions. I decided to take your advice and split them. – goalie35 Dec 13 '17 at 18:16
  • @oleksiy I know it's not necessary to include the = TRUE, I just find it makes it easier to read, especially for admins who don't necessarily have any programming experience. – Todd Sprinkel Dec 13 '17 at 20:13
  • This has nothing to do with programming, Excel-like formula experience. But it's definitely to what your preferences are. – o-lexi Dec 13 '17 at 20:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.