You need to sign in to do that
Don't have an account?
rbohn
Custom Button with conditional logic
I need a custom button who's logic is conditional based upon the STAGE field on the opportunity object.
Here is an actual example from Salesforce's help documentation. It's basically a conditional test of country and then invokes several different URLs.
{! IF(Sample.BillingCountry = "US", "http://maps.google.com/maps?q="&Sample.BillingStreet& "+"&Sample.BillingCity&"+"&Sample.BillingState&"+"&Sample.BillingCountry, (IF(Sample.BillingCountry = "UK", "http://maps.google.co.uk/maps?q="&Sample.BillingStreet &"+"&Sample.BillingCity&"+"&Sample.BillingCountry, "http://maps.google.com"))) }
For test purposes I've simplified the above example to the following: {! IF( ISPICKVAL (Opportunity.StageName, "Approved"), "http://www.google.com", "http://maps.google.com" ) } This button code, which is just a simplification of the Salesforce example, gives a "URL DOES NOT EXIST ERROR" and results in the following URL when invoked. https://na8.salesforce.com/servlet/http%3A%2F%2Fwww.google.com Can anyone provide pointers on how to implement a customer button that can invoke both external URLs and Visualforce pages?
Yeah, its not working as mentioned in the documents.
Here is the other way around you can try:
1. Change the Behaviour to 'Execute JavaScript"
2. Change Content Source to 'OnClick JavaScript"
Add the following code
Hope it helps.
Hi rbohn,
I've just created a bug for my team based on the behavior you've described - thanks for bringing it to my attention.
You can still use the URL return type if you do the following, and move the "http://" part of the URL outside the merge field context:
I'm the first to admit this is not the best way to do it. but it's probably the best workaround until we can get a fix in.
Oops - just noticed you have Visualforce and external URLs, which I'm assuming have mixed http and https.
I think my workaround will only work when the URL is the same for both type of links -- if you need the mixed case, you'll probably need to use the JavaScript button type and the workaround @crmtech21 suggested.