Search This Blog

Tuesday, October 25, 2011

Custom Lead Convert button...more URL hacking

Although the practice of URL hacking is not officially supported by Salesforce.com, it comes in handy. The concepts you will learn here apply to a lot of other areas in Salesforce.com where you can pass parameters in the URL. Today we will focus on the lead "Convert" button.

There are instances where we need to pass specific settings/values to the Lead Conversion page. For example, we may want to check off the "Do not create a new opportunity upon conversion." checkbox by default when a user clicks on the Convert button. Let's get to it.

1. Step one is to create a custom button to replace the standard "Convert" button. Click on:
Setup | Customize | Leads | Buttons and Links | New

2. Enter the required information. See image below



3. Enter the following code in the formula field:
window.location.href="/lead/leadconvert.jsp?nooppti=1&sem=1&tsk5_fu='Contact New Lead: {!Lead.LastName}&tsk4_fu={!Today()+3}&tsk13_fu=High&tsk12_fu=In Progress&id={!Lead.Id}&RetURL=/{!Lead.Id}";

The custom Convert button now does the following:

- Checks off the "Do not create a new opportunity upon conversion." (nooppti=1)
- Passes the Task Subject value for the task (tsk5_fu)
- Passes the Task Due Date of the Task (tsk4_fu={!Today()+3})
- Passes the Task Priority value (tsk13_fu=High)
- Passes the Task Status value (tsk12_fu=In Progress)

Here are all of the page elements (fields) and their respective id's:

- Send Email to Owner: sem
- Opportunity Name: noopptt
- Converted Status: cstatus
- Priority: tsk13_fu
- Status: tsk12_fu
- Comments: tsk6_fu
- Send email notification: email_followup
- Reminder: IsReminderSet_fu
- Reminder Date: reminder_dt_fu
- Reminder Time reminder_dt_fu_time

Don't forget to add your new button to your desired page layout(s). Enjoy.

46 comments:

  1. Can't thank you enough Javier!! Didn't know how to reply back to you from the answer on SFDC site but you are a lifesaver.. plus I've got this blog as a resource as well!

    LeAnn Scott

    ReplyDelete
  2. I'm very happy to hear that LeAnn. By the way, if you ever need reply to a question/answer on the Answer Community, all you have to do is login, click on your name at the top and then click either questions or answers on the left menu. This will allow you to locate the specific entry and then you can reply.

    ReplyDelete
  3. Hi Javier!

    Just a quick question on this - I have a customer who is concerned that by using this, if Salesforce were to ever move their org to a different server, that it would "break" this functionality. Do you know if that would happen? And what the odds would be that SFDC would move them?

    Thanks so much for your help, yet again!

    LeAnn

    ReplyDelete
  4. This would not be an issue with this specific example. You can test it by implementing it and then refreshing a sandbox or implementing it on a sandbox. If you look at the link, you can see that I don;t specify the Salesforce.com server.

    ReplyDelete
  5. This is great. Is there a way to set the converted status too? I don't see that parameter listed.

    ReplyDelete
  6. Javier,
    This is awesome. Do you know what the id is for a task type picklist... and how to find out what it would be or a comprehensive list of id's?
    Thanks!!!
    Chris

    ReplyDelete
  7. Christopher,
    Try tsk10_fu. For me, the easiest way to find out that the id of the field is to use Google Chrome as your browser. Go to the page where the field is displayed and right click on the filed. Then select Inspect Element and viola!

    ReplyDelete
  8. Christopher, the comment above assumes that you are talking about the Type field on the Task object. If you're not referring to this field, just use my method for finding the id. Good luck.

    ReplyDelete
  9. reminder_select_check <== not work
    IsReminderSet_fu <== work

    ReplyDelete
  10. Thanks! I must have copy/pasted the wrong value. Fixed now.

    ReplyDelete
  11. Great Post! I tried adding cstatus=Sales%20Qualified parameter I get the following error on clicking the convert button on leadconvert.jsp page. Can you say why i keep getting this?

    "
    Unable to Access Page
    The value of the "cstatus" parameter contains a character that is not allowed or the value exceeds the maximum allowed length. Remove the character from the parameter value or reduce the value length and resubmit. If the error still persists, report it to our Customer Support team. Provide the URL of the page you were requesting as well as any other related information. "

    ReplyDelete
  12. Can you post the entire URL that results from you clicking the Convert button?

    ReplyDelete
    Replies
    1. Hi Javier, we tried to set this too, as we wanted the default to be "qualified" but got the same error message. I did notice that it seemed to create a 2nd value called "qualified" in addition to the one on the picklist. Were you able to resolve this for Siri?

      Thanks!

      Delete
    2. Can you post the entire URL that results from you clicking the Convert button?

      Delete
    3. https://na3.salesforce.com/lead/leadconvert.jsp

      Unable to Access Page
      The value of the "cstatus" parameter contains a character that is not allowed or the value exceeds the maximum allowed length. Remove the character from the parameter value or reduce the value length and resubmit. If the error still persists, report it to our Customer Support team. Provide the URL of the page you were requesting as well as any other related information.

      Delete
  13. Can I integrate custom fields to the form?

    ReplyDelete
    Replies
    1. Unfortunately no. You would have to create your own VF Lead Convert page.

      Delete
  14. Any chance you can get the lead conversion page to direct to a different page other than the converted account page after submission

    ReplyDelete
  15. Unfortunately I don;t think there's a simple way to do it. You would need to override the Convert button on the lead screen to take you to a custom VF Lead Convert page that would redirect you to your desired page after the convert process takes place.

    ReplyDelete
  16. Is there a way to hide certain task fields on the same page?

    ReplyDelete
  17. Unfortunately not without having to override the Lead Conversion page with your own custom Visualforce page.

    ReplyDelete
  18. Thanks for your article, this really helped me a lot. I have a question...can we default recordtype for new accounts through this LeadConvert.jsp? If yes, then what should be the parameter name. Once again thanks..

    ReplyDelete
  19. Unfortunately I don;t think you can, since everything we are passing in the custom button is actually being captured on the conversion page form fields.
    Take a look at this free app and see if it fits your requirements.
    Lead - Smart Convert 2.0
    http://appexchange.salesforce.com/listingDetail?listingId=a0N30000007qq0iEAA

    ReplyDelete
  20. Hi Javier is it possible to set up the URL to default the Account name pick-list to say Attach to Existing:... I've setup 2 lead record types (New Lead) (Existing Lead). The Existing lead page layout has an Account lookup field which creates a relationship to the Account. I use a WF to update the Company field to the exact name which is on the Account lookup. When it's ready to covert - it then has a high probability of it matching to Existing Account upon conversion. Do you have the code for that field?

    Many thanks!!

    ReplyDelete
  21. I'm not sure. Try adding the following to your link:
    &accid=AccountNameGoesHere&acclkid_lkid=AccountIDGoesHere

    ReplyDelete
  22. Thanks Javier by luck I searched "acclkid_lkid=" in google and found another blog. It explains you need to add in the your lookup Id 3 times. The extra code is "acclkid_lkwgt=" . Together with this and setting up another custom New button on the Lead related list on the Account page it's quite seemless. http://techman97.wordpress.com/tag/professional-edition/

    Thanks again mate.

    ReplyDelete
  23. We’re using the NPSP and we created a new custom “Convert” button using >> window.location.href="/lead/leadconvert.jsp?nooppti=1&id={!Lead.Id}&RetURL=/{!Lead.Id}"; << from your answer on http://goo.gl/cohrY and it DID work perfect but ONLY if you uncheck the ”Overridden” option on the default NPSP Convert button (leadConvertOverride [npe01__leadConvertOverride] (Visualforce Page)). My concern is if we do not use the default NPSP Convert button that we might lose some NPSP lead conversation custom process. Do you have any insight or answers?
    Thanks Javier!

    ReplyDelete
  24. Hi Mark,
    Unfortunately I don't have enough experience with the NPSP edition to know what the ramifications would be.

    ReplyDelete
  25. I am using this window.location.href="/lead/leadconvert.jsp?sem=0&noopptt={!Lead.FirstName}+{!Lead.LastName} - +{!Lead.Due_date__c}&tsk4_fu={! Lead.Due_date__c }&tsk13_fu=High&tsk12_fu=In Progress&id={!Lead.Id}&RetURL=/{!Lead.Id}"; to populate 'Customer Name - due date' as new opptunity Name, Can I format the first Due_date_c field to mmddyy without the slashs. Please Advise.
    Thank You

    ReplyDelete
  26. I want to completely disable that option to check.Can I pass any parameter in url like we did for checking it!!!

    ReplyDelete
    Replies
    1. Unfortunately no. The only way to prevent it is to completely replace the conversion page with a custom VF page. Requires considerable amount of experience with Apex and VF.

      Delete
  27. How can we hack 'Save & new task' standard button? While clicking on this button I am losing the custom fields value which I have pre-populated for a standard task edit page from a custom button. Any help is much appreciated.

    ReplyDelete
  28. Nice post Javier, just used this : )

    ReplyDelete
  29. Is there any further reading you would recommend on this?

    Amela
    Lead conversion

    ReplyDelete
  30. Hi, I would like to just rename the convert button. I'm really bad with code stuff so I tried to modify your code in order to make the button redirect to leadconversion page:

    window.location.href="/lead/leadconvert.jsp?retURL=%2F{!Lead.Id}"

    Of course is not working because I don't know what's missing.

    Can you help me with this?

    Thanks on advanced!

    ReplyDelete
  31. Is there a way to have this convert page open in the Lightning UI? Currently, the page opens in the Classic view.

    ReplyDelete
  32. Nice blog..!
    Read More How to Qualify a Lead in Under a Minute.How to Qualify a Lead

    ReplyDelete
  33. Hi,

    I am trying to use this formula for a similar requirement but I am getting en error that the URL does not exist.

    ReplyDelete
  34. Event Lead Capture I think this is an informative post and it is very useful and knowledgeable. therefore, I would like to thank you for the efforts you have made in writing this article.

    ReplyDelete
  35. can the default record type be changed fro account and opportunity ?

    ReplyDelete
  36. I have requirement where in the convert screen i want to pre populate the record type based on lead record type in the account and opportunity.. which parameter or mapping i can use. Also want to remove the button do not create opportuntiy.

    ReplyDelete