0

I'm having trouble with multiple Validation cases when value is Yes or No: Here are the two conditions I'm trying to validate:

enter image description here

enter image description here

Here is what I have for the first condition (which works) but I need to allow for both conditions:

    `else if(objQuote.records.CAA_Agreement__c === null && objQuote.records.SYS_Account_Credit_Application__c !== 'No') 
{ 
alert("No CAA found! You have to attach the CAA Agreement to the Quote before you can create the BSO."); 
}`

Here are the field/value types: enter image description here

2
  • What is CAA Agreement (string, etc)?
    – sfdcfox
    Commented Feb 7, 2018 at 21:19
  • I updated the post to show field value types.
    – jlig
    Commented Feb 7, 2018 at 21:32

1 Answer 1

1

You need to combine and (&&) and or (||) operators, like this:

if(objQuote.records.SYS_Account_Credit_Application__c !== 'No' &&
    (objQuote.records.CAA_Agreement__c === null || objQuote.records.SYS_CAA_Active_Check__c !== 'Active')) {

Note here that you can apply De Morgan's Laws of Boolean Operations: NOT A OR NOT B can be expressed as NOT (A AND B).

if(objQuote.records.SYS_Account_Credit_Application__c !== 'No' &&
    !(objQuote.records.CAA_Agreement__c !== null && objQuote.records.SYS_CAA_Active_Check__c == 'Active')) {
1
  • sfdcfox, that seems to have did the trick! thanks.
    – jlig
    Commented Feb 7, 2018 at 21:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .