1

IF( NOT(ISNULL(Submission__c.DPM_Project__c)), ahttps://url.aspx?PROJECTID={!Opportunity.Name}&LOCATIONID={!Opportunity.Location__c}&INNCODE={!Opportunity.Inn_Code__c}&BRANDCODE={!Opportunity.Brand_Items__c}, ahttps://url.aspx?PROJECTID={!Lead.Name}&LOCATIONID={!Lead.Location__c}&INNCODE={!Lead.Inn_Code__c}&BRANDCODE={!Lead.Future_Brand__c})

I've had this formula in my custom button. But when saving, it appears to have an error.

{!IF( NOT(ISNULL(Submission__c.DPM_Project__c)), "ahttps://url.aspx?PROJECTID={!Opportunity.Name}&LOCATIONID={!Opportunity.Location__c}&INNCODE={!Opportunity.Inn_Code__c}&BRANDCODE={!Opportunity.Brand_Items__c}", "ahttps://url.aspx?PROJECTID={!Lead.Name}&LOCATIONID={!Lead.Location__c}&INNCODE={!Lead.Inn_Code__c}&BRANDCODE={!Lead.Future_Brand__c}")}

But for this one it doesn't have an error but when clicking the custom button, the link has a salesforce link before the link in the formula. Is there something wrong in my condition on both scenario? Thanks in advance.

NOTE: Don't mind the letter a before the https because i need to have at least 10rep to post more than 2 links. Thanks again.

  • what is the error you are getting while trying to save first version? You could try :IF( NOT(ISNULL({!Submission__c.DPM_Project__c})), "url.aspx?PROJECTID={!Opportunity.Name}&LOCATIONID={!Opportunity.Location__c}&INNCODE={!Opportunity.Inn_Code__c}&BRANDCODE={!Opportunity.Brand_Items__c}", "url.aspx?PROJECTID={!Lead.Name}&LOCATIONID={!Lead.Location__c}&INNCODE={!Lead.Inn_Code__c}&BRANDCODE={!Lead.Future_Brand__c}") – Anisa Jul 7 '17 at 6:36
  • What is the error you are getting? It would save us s lot of time – Eric Jul 7 '17 at 6:40
  • @Anisa sfdcfox gave me the answer already. Thank you for the help and time. – JMRAF69 Jul 7 '17 at 8:39
4

Merge fields start with {! and end with }. You don't use them in the middle of a formula. To merge in the middle of the formula, you want to use the concatenation operator, &. However, doing it the way you are doing it might break on some inputs.

I'd avoid possible encoding errors by using URLFOR, instead. Symbols such as &, =, and %, can cause parameters to get screwed up/misinterpreted, etc.

{!IF(ISNULL(Submission__c.DPM_Project__c),
  URLFOR("https://url.aspx", null, 
    [PROJECTID=Lead.Name, LOCATIONId=Lead.Location__c,
     INNCODE=Lead.Inn_Code__c, BRANDCODE=Lead.Future_Brand__c]),
  URLFOR("https://url.aspx", null,
    [PROJECTID=Opportunity.Name, LOCATIONId=Opportunity.Location__c,
     INNCODE=Opportunity.Inn_Code__c, BRANDCODE=Opportunity.Brand_Items__c])
)}

(Note: I reversed the true/false values to avoid the unnecessary extra NOT function, but this is mostly just a matter of preference).

| improve this answer | |
  • This works smoothly @sfdcfox. Thank you very much. – JMRAF69 Jul 7 '17 at 8:38
  • how can i replace the link with a custom label? Will I put $label before the PROJECTID? Thanks. – JMRAF69 Jul 7 '17 at 8:43
  • @JMRAF69 You can replace "https://url.aspx" with $Label.LabelForUrl (no quotes if you're using a label). – sfdcfox Jul 7 '17 at 12:30
  • @sfdcfox I need to display an error msg for the else condition, I am writing a window.alert('error msg') in the else part, but it redirect me to a new page and it displays this "This page isn't available in Salesforce Lightning Experience or mobile app". I have tried writing if{} else{} as well then it display error in my URL, I am calling a docusign URLFOR value if probablity is more than 50%. Appreciate your response. – user905 Jul 15 '19 at 4:23
  • @9codie05 That's not allowed. You can choose to not output a link at all, using something like {!IF(Probability<0.5,"You cannot generate a document at this time", URLFOR("url", recordId, [ params ], true|false)). – sfdcfox Jul 15 '19 at 4:48

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.