Skip to main content Take our 5-minute Community Survey. Open now through 4/11/2025. Click here to participate.

Hey Guys,

i am looking for a "best practice" solution, to create a conditionally url button. The button should be placed on the standard page layout.

Related to a value of the object, the button button should redirect the user to a page.

For example, if the status is x, redirect to a new task.

if the status is y, redirect to the homepage.

if the status is z, redirect to an external page.

Unfortunately, a javascript button is not a soultion for lightning.

I have created a controller and a methode to create a conditionally PageReference for each case. I dont think that this solution is best practice. Moreover, i used simply urls like

1new PageReference('https://...............+lead.id');

what is definitely not best practise.  So my button opens the page which is fireing the action methode automatically.

Conclusion, i am looking for : 

- a solution for lightning and classic

- a button placed on the standard page layout

- the button should redirect to different pages related to a value of the object

- a more best practice solution than mine 

I appreciate your help ! 

Cheers, 

Marry
5 answers
  1. Sep 5, 2018, 11:44 AM
    Hi Marry,

    It's very much possible to use an if statement in a custom formula. Please look at this code snippet. The below code snippet opens a google US search if the country is USA else google UK search. 

    {! 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"))) }

    This is from the help article: https://help.salesforce.com/articleView?err=1&id=customize_functions_i_z.htm&type=5

    Please let me know why you think you cannot use an if statement.

    Pradeep
  2. Sep 20, 2018, 10:10 PM
    This worked perfectly.... (passing Name OR Site value depending...... to a flow's variable.... so do not have to complicate the flow quite as much.

    This worked perfectly.... (passing Name OR Site value depending...... to a flow's variable.... so do not have to complicate the flow quite as much.
  3. Sep 6, 2018, 5:13 PM
    Hey Pradeep,

    my bad, its not possible to use actions like 'LogaCall' in an if statment. Thanks for your effort. I will mark your answer as best answer, because my question was formulated incorrectly.  Shame on me ;)

    Greetings Marry

  4. Sep 5, 2018, 9:06 AM
    Hi Pradeep,

    thanks for your reply. Unfortunately, it is not possible to use a if statement in a custom button formula. 

    I appreciate your help,

    Marry
  5. Sep 4, 2018, 9:42 PM
    Marry-

    You should be able to do this using Custom buttons. 

    Create the custom button for the object by navigating to  Account- Object->  'Button, Link & Actions'.  When you create the button use the formula to compare the object values.

    Defining custom button:

    https://help.salesforce.com/articleView?id=defining_custom_links_fields.htm&type=5

    Custom button with a formula 

    https://help.salesforce.com/articleView?err=1&id=customize_functions_i_z.htm&type=5

    Finally, use the custom button in your account page layout.

    Let me know if that helped?

    Pradeep
0/9000