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
mcc22mcc22 

How to use merge fields in formula for detail page button?

Hello, 
I am trying to build a detail page button on a custom object (Fulfillment__c) that allows a sales rep to easily track a package. The tracking number and shipping carrier are custom fields. The goal is to leverage the IF function to use the correct URL with (tracking number merge field) based on the shipping carrier. Here's the basic format of my formula.

{!IF(Fulfillment__c.ShippingCarrier = "UPS","https://www.ups.com/{!Fulfillment__c.Tracking_Number__c}",
(IF(Fulfillment__c.ShippingCarrier = “FedEx", ”https://fedex.com/{!Fulfillment__c.Tracking_Number__c}”,
(IF(Fulfillment__c.ShippingCarrier = “DHL, ”https://dhl.com/{!Fulfillment__c.Tracking_Number__c}”
   )))))
}
I receive a syntax error on the second IF but I'm not exactly sure the cause. Is it possible to use merge fields in the formula? TIA
ShirishaShirisha (Salesforce Developers) 
Hi Matt,

Greetings!

 The way of using the merge fields seems good for me as suggested here (https://help.salesforce.com/articleView?id=sf.links_merge_fields.htm&type=5).

I would suggest you to double check,if the field ShippingCarrier data type.If it text then the above formula should be valid.If it is picklist then you would need to use ISPICKVAL function as suggested here.
 
IF(ISPICKVAL(Type, "Manufacturing Partner")
Please mark it as best answer if it helps you to fix the issue.

Thank you!

Regards,
Shirisha Pathuri
 
mcc22mcc22
Hi Shirisha, 

Thank you for the reply. Yes, the data type is text.

I noticed there's a missing " in the example formula I included above- it should be "DHL". Either way, I still receive the syntax error. 

The URLs work as expected separately, my trouble is getting them to play nice together. Any additional support is greatly appreciated. 
mcc22mcc22
Syntax fixed. Now I'm receiving "Error: Enter a URL that is valid and well-formed." Plenty of posts on this subject but no clear answers to why this happens.