0

I do not find anyway that you can validate a valid url when the user enters in the standard page so I come up with this validation and I need little help to fix it.

I'm using BEGINS to see if the url starts with HTTP or HTTPs

My scenario is,

--Validation should ONLY fire when Attachment == false
-- When the users enters the URL make sure the URL starts with http:// or https://

Attempted:

if(Attachment__c == false && NOT(ISBLANK(url__c), true (BEGINS(URL__c, "https://")))
  • try with this IF(AND(Attachment__c == false, OR(ISBLANK(url__c), NOT(BEGINS(URL__c, "https://")), NOT(BEGINS(URL__c, "http://")))), true, false ) – Ratan Paul May 9 '16 at 17:10
  • didn't work, even though after entering the url starting with http:// still thinks its not a valid url – Nick Kahn May 9 '16 at 17:23
  • downvoters: care to explain why you think you should down vote? – Nick Kahn May 9 '16 at 22:05
3

Try this:

AND(
    Attachment__c == false,
    NOT(ISBLANK(URL__c)),
    NOT(BEGINS(URL__c, "https://")),
    NOT(BEGINS(URL__c, "http://"))
)

You don't typically need an IF statement for a validation rule. A validation rule is basically the conditional portion of the IF statement and returns true or false based on the conditional. True means display the error, false means do not display the error.

  • Perhaps worth mentioning there are other valid protocols, e.g. ftp://, etc. – Adrian Larson May 9 '16 at 18:31
  • 1
    To add to @AdrianLarson, I wanted to note that this will allow http://&5# or http://mike, neither of which are valid URLs. – Charles Koppelman May 10 '16 at 18:16
0

Perhaps, only validation for the URL starting with "http" would be enough:

NOT(
 OR(Attachment__c,
 ISBLANK(URL__c),
 BEGINS(LOWER(URL__c, "http"))
)

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.