I'm trying to create a custom clone button in the opportunity object.

    {!IF( ISPICKVAL( Opportunity.Type , "New Business") , "/{!Opportunity.Id}/e?
    clone=1&retURL=%2F{!Opportunity.Id}&00N90000008KH67=", "/{!Opportunity.Id}/e?

Is it possible to use functions within URL button

  • Yes, you can use the IF function in a detail page link. Can you please elaborate on what you mean by But I'm not able to use If-Else functions in the formula field? Oct 12, 2020 at 16:47
  • Hey sorry, my bad i have updated the question. how to handle the above scenario
    – Pavan tej
    Oct 12, 2020 at 17:01

2 Answers 2


You can use if condition inside an URL button in Salesforce. For example, see below button formula:-

{!IF( ISPICKVAL( Opportunity.Type , "New Business") , URLFOR('/'+Opportunity.Id+'/e? clone=1&retURL='+Opportunity.Id), URLFOR('/'+Opportunity.Id+'/e'))}

The key point is:-

  1. Do not use curly braces inside if condition.
  2. Use URLFOR function to generate URL inside if condition

enter image description here

  • Hey @sanket it worked very well but how to include custom fields
    – Pavan tej
    Oct 16, 2020 at 14:25
  • The same way you handle standard fields Oct 16, 2020 at 14:29
  • Hey, @sanket when i click this button and save the record it actually updating the existing record instead of creating a new one.
    – Pavan tej
    Nov 11, 2020 at 10:58

I have tried the Sanket Kumar solution but it didn't work completely, Instead of cloning the opportunity, it is opening the edit window of the current opportunity.

But the URLFOR function is working as expected when i made some changes. I'm updating my answer maybe it would be helpful for others

{!IF( ISPICKVAL( Opportunity.Type , "New Business") && 
NOT( ISPICKVAL( Opportunity.StageName , 'Closed Won')),

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .