0

I am trying create a rule that will fire if the field is not blank and the length of the field is 7 or 10 or if the field does not start with 609. Here is what I have. The problem I had was the rule was not firing as expected as a result of my logic.

AND( NOT(ISBLANK(Phone__c)), OR( LEFT(Phone__c, 3) <> "609",
LEN(Phone__c) <>7, LEN(Phone__c) <>10 ) )

  • And...what is going wrong? – Adrian Larson Oct 6 '15 at 22:38
  • The length will always be either not 7 or not 10, this should fail every record. – Adrian Larson Oct 6 '15 at 22:38
2

The issue is the logic for the 7 or 10. AS it is currently written if it - 7 then does not = 10 so result is true

try this

AND( 
  NOT(
    ISBLANK(Phone__c)
  ), 
  OR( 
    LEFT(Phone__c, 3) <> "609",
    AND(
     LEN(Phone__c) <>7, 
     LEN(Phone__c) <>10 
    ) 
  )
)

Now if it =7 or = 10 then result is false, anything else result is true

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.