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
AceldamaAceldama 

Issues using BEGINS in a validation rule

Having issues getting a VR to work.  I'm trying to force that all entries start with http:// or https:// in both lower and upper case:

 

OR (
NOT(BEGINS(Course_Information__c,"http")),
NOT(BEGINS(Course_Information__c,"https")),
NOT(BEGINS(Course_Information__c,"HTTP")),
NOT(BEGINS(Course_Information__c,"HTTPS"))
)

 

Only thing that works is using it a single time:

NOT(BEGINS(Course_Information__c,"http"))

Best Answer chosen by Admin (Salesforce Developers) 
m.elmoussaouim.elmoussaoui

Hello,

Try this :

AND(NOT(BEGINS(LOWER(Course_Information__c) , 'http')), NOT(BEGINS(LOWER(Course_Information__c) , 'https')))

By using the 'LOWER' function you don't have to check for the upper/lower case.

 

Good luck 

 

All Answers

m.elmoussaouim.elmoussaoui

Hello,

Try this :

AND(NOT(BEGINS(LOWER(Course_Information__c) , 'http')), NOT(BEGINS(LOWER(Course_Information__c) , 'https')))

By using the 'LOWER' function you don't have to check for the upper/lower case.

 

Good luck 

 

This was selected as the best answer
ryanjuptonryanjupton

You could possibly also simplify it a bit with a REGEX

 

NOT( REGEX( LOWER(Event_URL__c) ,"^(http|https)?://"))

 

harsha__charsha__c

Hi 

 

I guess usage of braces might be a problem.

 

Try this once

 

OR (
NOT(BEGINS(Course_Information__c,"http"),
NOT(BEGINS(Course_Information__c,"https"),
NOT(BEGINS(Course_Information__c,"HTTP"),
NOT(BEGINS(Course_Information__c,"HTTPS")
)

 

I have just removed the double braces after each line

AceldamaAceldama

Thanks M!   That one worked.

AceldamaAceldama

Tried that first, but got an error that I was missing a bracket.  Would still like to know what was wrong with my original formula.  When I activated it, it would accept none of my pre-conditions.  Odd