1

I am trying to create a custom URL button in salesforce and when hitting save getting the below error:

Error: Enter a URL that is valid and well-formed

This is the formula I am using:

{
!IF( 
AND(
Project__c.RecordType  = 'Minor Works Project',
{!NOT(!ISPICKVAL(Project__c.Type__c, 'Training'))})
,
URLFOR("https://datacom--uat.lightning.force.com/lightning/r/Report/00Op0000000cBzHEAU/view?", null, 
    [fv1=Project__c.Client_Contact__c]),
 {!IF( 
AND (
Project__c.RecordType  = 'Minor Works Project',!ISPICKVAL(Project__c.Type__c, 'Training')
),
URLFOR("https://datacom--uat.lightning.force.com/lightning/r/Report/00Op0000000cBzHEAU/view?", null, 
    [fv1=Project__c.Client_Contact__c]), 
URLFOR("https://datacom--uat.lightning.force.com/lightning/r/Report/00Op0000000cBzHEAU/view?", null, 
    [fv1=Project__c.Client_Contact__c]))}
)
}

PS: I just copied the URLFOR statement from a previous Help article. I am not sure why and if there is a need for the Null in the URL I used

Any help is deeply appreciated.

1 Answer 1

1

You need to remove the extraneous {! and }. Once you start and close a formula with {! and } no other merge field syntax is required

Just looking at the first 5 lines, you have

{
!IF( 
AND(
Project__c.RecordType  = 'Minor Works Project',
{!NOT(!ISPICKVAL(Project__c.Type__c, 'Training'))})  <== remove merge syntax
...

you need

{
!IF( 
AND(
Project__c.RecordType  = 'Minor Works Project',
NOT(ISPICKVAL(Project__c.Type__c, 'Training')))
...

as an aside, these complex formulas are best debugged by starting with the smallest formula, confirming it compiles/works, then adding pieces in one at a time

Also, use relative references in your URLFOR to make it easier to deploy - though the hardcoded reportIds will also yield deployment issues

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.