0

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?
clone=1&retURL=%2F{!Opportunity.Id}")}

Is it possible to use functions within URL button

2
  • 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? – Drew Kennedy Oct 12 '20 at 16:47
  • Hey sorry, my bad i have updated the question. how to handle the above scenario – Pavan tej Oct 12 '20 at 17:01
1

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

3
  • Hey @sanket it worked very well but how to include custom fields – Pavan tej Oct 16 '20 at 14:25
  • The same way you handle standard fields – sanket kumar Oct 16 '20 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 '20 at 10:58
0

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')),
URLFOR($Action.Opportunity.Clone,Opportunity.Id,['retURL'=Opportunity.Id,'00N2s000000uhbh'=1,
'00N6F00000EYw00'=0],true),
URLFOR($Action.Opportunity.Clone,Opportunity.Id,['retURL'=Opportunity.Id,'00N2s000000uhbh'=0,
'00N6F00000EYw00'=0],true))}

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.