Tutorials / Users

Salesforce URL Hacking – Tutorial

By Ben McCarthy

If you are using Salesforce Lightning Experience, please see this guide for the correct way to URL Hack, this post applies only to Salesforce Classic.

READ MORE: Salesforce URL Hacking for Lightning – Tutorial

After briefly covering what Salesforce URL Hacking is in my 4 Clever Hacks with Salesforce buttons post I decided that this would require a separate post being the beast of a topic that it is! But please don’t be put off by that statement, URL Hacking does take some learning but it is by no means an advanced topic or require you to be a developer. It will also teach you a lot about how URL’s work and help you do similar techniques in Salesforce and other systems.

As a quick recap – URL hacking is the process of pre-populating data in a new record with data from a record you are currently working off using a custom button to launch this new record. Check out my 4 Clever Hacks post above for an example, as  I will be using a similar example through this tutorial.  In a nutshell though I will be populating a new custom object called Resource Request from data in the Opportunity.

Step 1 – Create a button and add it to your page layout

The best place to start with creating a custom button to URL hack is to actually create the framework and add the button to the page layout so we can start testing after each step is completed. So go to your object and Click “New Button or Link” in the section Buttons, Links & Actions. Lets give our new button a name and select List Button. This means it can be placed in a related list and not on top of a record. We also want to make sure we have the behaviour set as the below and the content source as URL.

Screen Shot 2015-02-06 at 16.39.31

As we want this button to launch our object and fill it with information, lets deal with the actual launching of the object first. The button we’re creating already presumes that we want to launch information inside of Salesforce, so hidden away out of site of the text box you will with your URL will be “https://na15.salesforce.com/” with whatever instance of Salesforce you are on. This means we only need to fill in data after the /.

The URL to actually launch our object looks a bit like this “/a0U/e”. The three letter code is your object code. You can find out your object code by creating a new record and looking at the first part of the URL, mine looks a bit like this. The “e” refers to edit, which means we are going to the edit page of this object.

https://na15.salesforce.com/a0U/e?

So copy that part after the .com and up to ? and paste it into your new custom button you have created so it looks like this.

Screen Shot 2015-02-06 at 16.51.51

We’re now ready to add this to our page layout and launch it! To do this were going to need to go to the master object where this button is going to be launched from. In my example this is the opportunity. Edit this page layout and scroll down to your related list. You then want to hit the spanner.

Screen Shot 2015-02-06 at 16.53.14

Once here you can click on the Buttons tab and move across your new button to the selected side.

Screen Shot 2015-02-06 at 16.53.46

We’re done! Give your button a click. It should launch into the edit page for your new object.

Step 2 – Pre-populating some basic text values

Now we’ve set up our basic custom button that launches our edit page for the new record we want to create, lets start populating some data. The reason this step is to populate some basic text values, is because the way to populate Lookup fields is very slightly different.

So to start off pre-populating text values we need two things. The ID of the field we wish to populate and the value of which we would like to populate this with.

  1. To get the ID of the field we wish to populate go to the relevant object in setup and click on the field we wish to populate. If you check out the URL when you’re on this page, you can see the unique ID given to this field.

https://na15.salesforce.com/00Ni000000EpsgY?setupid=CustomObjects

  1. The value of which we would like to populate this with is found in the form of a merge field. These can be explored on the custom button page and looks like the below. As I am working off an Opportunity I can grab fields from the Account and Opportunity page because of the relationship.
Screen Shot 2015-02-08 at 13.37.20

Now, to turn this into something that actually works! Lets go to our custom button editing page and enter a “?” after our little URL. This acts as a separator and will allow us to enter the next part. The next part will just require you to enter the ID of the field you grabbed earlier with “=” and then the merge field value.

/a0U/e?00Ni000000EpsgY={!Opportunity.Description}

If you click on your list view button now, you will be hopefully able to see a pre-populated value in your specified field. If this does not work be sure to check out your URL on the page to make sure it looks correct. My button that I have just made will look like this..

https://na15.salesforce.com/a0U/e?00Ni000000EpsgY=This+is+a+test

As you can see we have our field URL and then the value afterwards. If the value is not present for any reason you can presume that either data is not in that field at the moment or the merge field is wrong or not accessible.

Step 3 – Pre-populating lookup values

You may have noticed that if you are following a similar example to mine, your lookup value will not be pre-populating like the default “New” button does. This is because behind that new button, Salesforce is bringing over the value from the previous object, as our button is fresh, we will need to do this ourselves (and with any other lookup values we have). They do differ slightly from basic text values which I will explain below.

To populate a Lookup value we need the field ID as before but this time we need to add CF to the front of the ID so it looks something like this – CF00Ni000000EpsgO. This is required when populating a custom lookup field.  The first part to populate a lookup value is to grab the name of the record we are populating. So using the method before but with the added CF you can expect your button URL to look like this

/a0U/e?CF00Ni000000EpsgO={!Opportunity.Name}

The next step is to grab the ID of the record we wish to populate. This time though, we are going to add “_lkid” to the end of our field ID (plus the CF we added on earlier). This lkid parameter is telling Salesforce this is a lookup field. So it looks a bit like this.

/a0U/e?CF00Ni000000EpsgO={!Opportunity.Name}&CF00Ni000000EpsgO_lkid={!Opportunity.Id}

Again nothing too fancy we’ve just added some extra parts to the ID and referenced this field twice, grabbing the ID and the Name of the record.  Please note the “&” used to separate the URL when referencing different fields. You can also see this being used below where I have the full URL used for this demonstration.

/a0U/e?CF00Ni000000EpsgO={!Opportunity.Name}&CF00Ni000000EpsgO_lkid={!Opportunity.Id}&00Ni000000EpsgY={!Opportunity.Description}

Bonus Tips

  • As mentioned earlier, if something isn’t working, always checkout the URL on your object after you click your custom button. This will show you whether data is getting as far as being populated into the URL.
  • You should always add &retURL={!Opportunity.Id} to your button. Where Opportunity.ID is the ID of your master object. This will make sure your return to this object if you press cancel while creating a record.
  • URL hacking may not be the best thing to use if you have a very complex process that requires a lot of data to be transferred. Please look to APEX in these circumstances.
  • If you have multiple record types, you can easily pass in the ID of the record type using this format – &RecordType=abc. With abc being a fixed value or possibly a merge field with your Record Type ID (This can be found on the record type page)

The Author

Ben McCarthy

Ben is the Founder of Salesforce Ben. He also works as a Non-Exec Director & Advisor for various companies within the Salesforce Ecosystem.

Comments:

    david
    March 09, 2015 3:28 am
    hi, is there a way to do this for a case? thanks!
    ben@ben-mccarthy.com
    March 09, 2015 8:59 am
    Hi David, Yup! This can be done for nearly any object you can place a button on. All you have to do is built the button as per the instructions but getting the Case URL, which I believe looks a little like this... /500/e? Thanks! Ben
    David
    March 09, 2015 11:55 pm
    Hi, here is the URL i when I click on "new email": _ui/core/email/author/EmailAuthor?p2_lkid=003j000000C5Xo7&rtype=003&p3_lkid=500j0000002TVF1&retURL=%2F500j0000002TVF1 any ideas? thanks for putting up your site!
    ben@ben-mccarthy.com
    March 10, 2015 10:01 am
    Hi David, so for the basic button you will need everything before p2_lkid. I would recommend looking at my article here - https://www.salesforceben.com/salesforce-email-url-hack-tutorial/ No problem at all!
    David
    March 10, 2015 4:12 pm
    Thanks again!
    Jeremy
    March 31, 2015 8:53 pm
    I'm creating a New button for a child record. The child records have several lookup fields that are not on the parent. I'd like to hardcode into the URL a value (id) for a lookup field. Here is the section, ...&CF000NF0000008yBTy__lkid=a2tZ0000000HKzN&CF000NF0000008yBTy={!rstk__rtproc__c.Name} where: 00NF0000008yBTy = the field i want to populate on the child, a2tZ0000000HKzN = hardcoded lookup record ID {!rstk__rtproc__c.Name} = the name of the record being looked up. Help would be awesome!
    ben@ben-mccarthy.com
    March 31, 2015 9:09 pm
    Hi Jeremy, Your URL looks fine and you can absolutely hard code the values. Is this not working at the moment?
    Jeremy
    March 31, 2015 9:41 pm
    Not working! I don't know why it won't populate on the screen. Here's the full button: https://cs11.salesforce.com/a2v/e?CF00NF0000008yAJA={!rstk__rtrouthdr__c.Name}&CF00NF0000008yAJA__lkid={!rstk__rtrouthdr__c.Id}&CF000NF0000008yBTy__lkid=a2tZ0000000HKzN&CF000NF0000008yBTy=MFG&Name={!rstk__rtrouthdr__c.Name}&retURL={!rstk__rtrouthdr__c.Id} Note: these are fields built by a managed package, I don't know if possibly there is some problem there, but seems unlikely. I'm using a standard page layout. I can pre-populate regular (non lookup ) fields without an issue. page layout for reference: http://i.imgur.com/pRToH6u.png
    Jeremy
    March 31, 2015 9:50 pm
    Woah, I think I got it. I think it was something to do with the field ID pre-fix. I was using CF0 rather than CF. https://cs11.salesforce.com/a2v/e?CF00NF0000008yAJA={!rstk__rtrouthdr__c.Name}&CF00NF0000008yAJA__lkid={!rstk__rtrouthdr__c.Id}&CF00NF0000008yBTy_lkid=a2tZ0000000HKzN&CF00NF0000008yBTy=MFG&Name={!rstk__rtrouthdr__c.Name}&retURL={!rstk__rtrouthdr__c.Id}
    Maria
    April 13, 2015 10:26 am
    Hi, I am trying same thing to create new task so fields get populated from previous tasks. however not sure why it's not working. also the layout has turned out to be a bit odd, showing a webpage within a webpage.
    Ben McCarthy
    April 13, 2015 10:44 am
    Here is one from my Dev Org that I made a while back. its on the account object as you can probably tell. The ID's for the fields aren't immediately obvious. What I had to do was right click on the field and click "Inspect Element" on chrome. I could find the ID of the field from here. The below, tsk6 currently populated the comment box with ben! Hope this helps. /00T/e?what_id={!Account.Id}&retURL=%2F{!Account.Id}&tsk6=ben
    Brenna
    May 19, 2015 11:31 pm
    I am trying to create a new button to create an opportunity from another opportunity, like a child. The child will have many of the same fields and I would like the new opportunity name to be the original opportunity's name appended with "2". I can't find the field ID for Opportunity Name? Do standard fields have a different way of finding the field ID?
    Ben McCarthy
    May 20, 2015 9:15 am
    Standard fields are a bit tricky. To get the ID of the fields its best to use chrome. right click on the field in salesforce and click inspect element. This will show you the field name in the code. The Id you need though is opp3 so &opp3=BensOpp Hope this helps!
    Brian
    June 30, 2015 9:15 pm
    REALLY weird situation. We have a validation rule on a picklist field (Substatus__c) that ensures Status cannot be Open if Substatus is not blank. I created a button to create a new case. Substatus is not used on this record type, so is not on the page layout. When I trigger the button and save the case (Status = Open substatus is not on page layout so therefore is blank), it fires the validation rule. If I PUT the substatus field on the page layout, and perform same situation, it WILL save solely because the field is visible ON the page layout... I tried forcing the field to be blank, but it still triggers the val rule. Any way to force the field to be blank in the button, or know why this URL hack is firing the validation rule?
    Rey
    August 17, 2015 9:02 pm
    I am trying to go two levels deep with my URL hack can this be done? So I have a Quote object, that is created from an Oppty, and that Oppty is created from an Account record. I would like to capture a field value from the Acct record and pass it to the Quote record, can this be done? I can get Oppty field values (Opportunity.Name) passed to my Quote no problem, but I want a value from Account record to go to the Quote record, help please. Thanks.
    Ben McCarthy
    August 18, 2015 8:58 am
    Hi Rey, I don't think you could do this just with a button. However, you could quite easily use a formula field on the Opportunity to grab account data then pass this into the Quote, does that make sense?
    Fraidy
    August 26, 2015 8:19 pm
    Hi, Thank you for this! I am trying to populate standard lookup fields. How do I find the id's for that?
    Ben McCarthy
    August 27, 2015 9:23 am
    Hi Fraidy, Standard fields are a bit more tricky. If you use Chrome as a browser, go to the field in Salesforce and right click on it, select inspect element. This will show you the "code" for the field. Depending on what field it is it may look something like this for opportunities "opp3". I feel another post coming on this! Hope this helps, Ben
    Kevin Gibbs
    September 10, 2015 4:44 am
    Ben, I have some pretty advanced URL Hacks going but run into an "unterminated string literal" javascript error when attempting to pass a Text Area field value in a Service Cloud Console hack. I suspect it has to do with line breaks in the Text Area field breaking the URL. Any tricks for passing the Text Area fields across a URL Hack?
    Rey
    September 15, 2015 1:05 pm
    Hi that does make sense, but trying to avoid creating another field on the Oppty object which I would have to do based on your comment correct? We already have so many fields on our Oppty object, so we are trying to watch that now. Any other suggestions? The field that resides on the Acct object I want is called Acct Mgr. I want to pass Acct Mgr to my Quote object. Do you think I could just create the new field (Account Manager) on my Quote object and then use a Trigger/Field Update to populate the new field on the Quote object after the Quote object is saved?
    Curt Griffin
    September 21, 2015 5:58 pm
    Ben Great tutorial! I'm trying to populate the Asset lookup field to create an RMA Record that is a junction object between the Asset and Case. Asset Name ( {!Case.Asset} ) is not unique, so I get multiple matches in my RMA Hack URL Button. Any suggestions to prevent specify the name of the Asset Record Identified in the {!Case.AssetId}? Here is my URL Button code: /a03/e? CF00Nq0000000oXen={!Case.CaseNumber}& CF00Nq0000000oXen_lkid={!Case.Id}& CF00Nq0000000oXes.lkid={!Case.AssetId}& CF00Nq0000000oXes={!Case.Asset}& retURL={!Case.Id} Thank you Curt
    Ayo
    October 01, 2015 10:49 am
    Hi Ben, Please I am trying to create a button on a custom object where when the user clicks on the button on a record type A, It opens Record Type B in another page without changing the record type of the record itself..Please help. Thanks
    Ben McCarthy
    October 01, 2015 10:58 am
    Hi Ayo, This will probably be because it will automatically go to the default record type. I think you will need to put a parameter in your URL hack which looks like this &RecordType= and then put the record type ID that you wish it to be. Hope that helps, Ben
    Aashish
    October 23, 2015 10:11 am
    I have a rare situation. Custom object has two lookup fields and both have same Id of 15 characters: 00N23000000FrIh and 00N23000000FrIH. So only difference in their Ids is the last alphabet. One has small h and other has capital H. Both fields are present in the pagelayout. Now the issue: When I am trying to populate value in one field, it is actually being coming in the other field. URL and HTML both are case insensitive languages. Can anyone suggest some solution.
    Aashish
    October 23, 2015 10:14 am
    Continuous to my previous comment. Making Ids of those fields to 18 characters does not help.
    Idan
    November 22, 2015 1:12 pm
    Hi Ben - many thanks for valid, active and useful site. If I may: Using custom URL button - I want to set the cancel/return url AFTER the recordtype was selected: /setup/ui/recordtypeselect.jsp?ent=Case &save_new_url=/500/e &cancelURL=/{!Presales_Activity__c.Id} &retURL=/{!Presales_Activity__c.Id} Regards,
    Derek
    December 08, 2015 3:03 pm
    Hello! Would you have any suggestions for how this might look for replicating the Add to Campaign standard button on a Contact layout? Looking to mimic the functionality but set the default to 'All Campaigns' and add initial search criteria. Cheers.
    Nate
    December 09, 2015 3:22 pm
    Same issue here. I've been doing these button hacks for several years and this has always been an issue. Salesforce won't comment on the issue because button hacks are not supported. I'm hoping some genius out there has figured it out.
    Raj
    December 15, 2015 2:07 pm
    Hi, Is URL Hacking is the best way to customize the button in Salesforce. I'm new to Salesforce. I dont know whether it's the best way or not
    Richard
    February 17, 2016 4:29 pm
    Hi Ben, Great site and always very useful. I have a URL hack button on an Opp to clone a record and pre-pop certain fields. Can i include something in the URL to update a custom check box field on the record being cloned, rather than it goes straight to the new, cloned record? If i can solve this i'll be the happiest Admin on the planet.
    Katie
    February 24, 2016 8:08 pm
    Hi Ben, This tutorial has been great! I have created a custom oppty button that populates the description field. My company wants to the button to enter questions into the description to prompt answers from field. Any idea if we can "return" within the description box to get the questions on separate lines in the box. Can this be done within the custom button?
    Thebowshow
    March 09, 2016 3:27 am
    Ben, The Man, the Legend! Can you speak to the changes in URL hacking with the recent Salesforce platform upgrade to lightning? I've read in a few posts that it will make hacking urls in these ways very limited. That's a huge bummer since I'm just getting the hang of it! Also +1 superhero status if you (or anyone) has a "save and new" hack, where I can tranfer the same values from my original "new" click into my save and new button click. Thanks.
    Ben McCarthy
    March 09, 2016 7:39 am
    Hey Josh, My reputation precedes me! Unfortunately what you've heard is true, it will no longer work properly with the way that Lightning is designed. This was always kind of expected seeing as URL "Hacks" were never a supported method of doing something. However, from what I've heard, depending on the solution you have designed Quick Actions might be able to solve a lot of your problems. They might not be able to replicate them 100%, but you can use a combination of Quick Actions and Process builder to hopefully create a similar solution. Hope this helps! Ben
    Brian Fey
    March 18, 2016 8:04 pm
    So, what is the real risk of developing a bunch of these buttons -- and having them all crash because your ORG has been moved to a different server -- or whatever event could cause such a thing to happen? BFey
    Ben McCarthy
    March 19, 2016 12:54 am
    Hi Brian, these "hacks" are of course not supported by Salesforce but have been around for a number of years and are generally accepted as a valid feature. Moving to another server would not affect this as they append parameters after the server part of the URL. Thanks Ben
    Bailey
    March 24, 2016 6:42 pm
    Hi Ben, I'm assuming this isn't possible but I figured I'd inquire anyway.... I would like to customize the button on the quote layout when viewing a newly generated PDF (It's a pop-up that shows over the actual layout of the quote to let you preview the PDF before sending.) Do you think it would be possible to customize that button to prepopulate the "Send to" email field?
    onesh
    April 04, 2016 1:53 pm
    Hi Ben, This Tutorial has been great. Is it possible to auto-populate fields to a Custom VF page, how should i specify the link in the button. (I Want to Auto-populate fields from Opportunity to a Custom VF page with Standard Controller as Quote) Thanks, Onesh
    Nihar
    April 07, 2016 2:22 am
    Hey Ben, Can you please tell me how can i pass value in standard field Using URL (I use custom button) ?? Thanks -Nihar
    Lokesh
    April 11, 2016 3:19 pm
    If you want to find out the Id of 'Account Name' standard field from Account object (using chrome browser) - Click on new Account - Right click and select 'View page source' - Search with string '>Accoutn Name<' you can find line something similar to *Account Name here acc2 is the id
    Emma
    May 24, 2016 10:16 am
    Hi Ben, I have a custom object with 2 different record types. When I click the New OBJECT button, I want to still be able to select the record type instead of it just using the default record type. The fields I then want to pre-populate will be the same on both record types but I don't know how to get to this recordselect screen and then pass over the value. Any help would be greatly appreciated! Thanks, Emma
    Harshit Agrawal
    June 08, 2016 2:57 pm
    Hi Ben, How can we populate the value to hidden field on standard edit page from custom button? I want to populate the value to a field which is not added on page layout. When I click the custom button then it redirects to Contact standard edit page in which I need to populate the dynamic value coming from custom button to a field which should not be displayed to users so it is not added on page layout. I want to use that field value in Contact Trigger. Is there a way to do this? I know, VF page is an option but don't want to create VF page for this single requirement.
    Greg M
    June 28, 2016 8:17 pm
    We have a NEW button for a custom Object that's opens up from the Contact tab with a couple pre-populated fields. The pre-populating is working great but the standard page for the new custom object record is opening inside the Contact tab where it was called from, so the users sees 2 rows of tabs. Is there a setting to make the New record page open without being inside the Contact page?
    Ben McCarthy
    June 28, 2016 8:18 pm
    Hi Greg, you will need to change the open behaviour on the custom button. Hope this helps!
    Greg Mitchell
    June 28, 2016 9:13 pm
    Hey Ben, Please disregard my question from today about having the new record page visible within the Contacts tab, as this was just a simple setting on the List button setup. Thx's Greg
    Marcs Winn
    June 29, 2016 9:24 pm
    How about a standard field id on a custom object? For instance, the field that is required to name the detail record of a master detail relationship. I have a choice of a text or number in the setup, here I have chosen text but would like it prepopulated with data from the Master and workflow to update after saved based on picklist values chosen on the the detail. I have looked through the code and cannot find a solution.
    Laura Walker
    July 11, 2016 8:33 am
    Hi I have a custom button that is trying to create a case and have a lookup to the record I created it from with an ID of cas3. everything works apart form the lookup. Any ideas please? Thanks https://eu2.salesforce.com/500/e?&RecordType=012b0000000Tmbt&cas3_lkid={!Case.Order_NumberId__c}&cas3={!Case.Order_Number__c}&cas11=Fraud&cas14=Requesting ID&cas7=In Progress&00Nb00000094z0T=Orders&00Nb00000094z0S=Fraud
    Laura Walker
    July 11, 2016 8:45 am
    I may have got the ID wrong so have also tried this https://eu2.salesforce.com/500/e?&RecordType=012b0000000Tmbt&CF00Nb000000730E6_lkid={!Case.Order_NumberId__c}&CF00Nb000000730E6={!Case.Order_Number__c}&cas11=Fraud&cas14=Requesting ID&cas7=In Progress&00Nb00000094z0T=Orders&00Nb00000094z0S=Fraud But this does not work either Thanks
    Dian Omaoas
    July 14, 2016 5:22 pm
    Hi! This tutorial was awesome!! Can you give me some advice as to how I can auto populate multiple fields in just one click of a button? I wanted to auto populate 3 fields when creating a task. So far I am only able to auto populate one field. I tried using the && but it did not work. I'm not a developer tho, so maybe you have something that can solve this? Thank you in advance!!
    Arise Johns
    August 31, 2016 11:27 am
    Hi, Thank you for sharing this useful article! I am trying to populate standard lookup fields. Where can I find the IDs for this? And what will happen if the Id is not correct?
    Gil
    September 22, 2016 9:42 am
    Hi Ben, Thank you for this great tutorial. I followed the logic and created this button when i create a custom object record from Contact. /a23/e?CF00NK0000001uGhj={!Account.Name}&CF00NK0000001uGhj_lkid={!Account.Id}&CF00NK0000001uGfs={!Contact.Contact_Full_Name__c}& CF00NK0000001uGfs_lkid={!Contact.Id}& 00NK0000001uHXt="Potential" This works perfectly on my Sandbox but when I set it on my Production environment it does not work. I made sure to change the field unique code and also the object code is different in Production namely /a26/ Could you please advise me what am I doing wrong or missing out here?
    Gil Levy
    September 22, 2016 10:04 am
    Hi Ben, I am not sure if my previous post was received therefore I send another one. I created this URL hack on a button that creates new custom record from Contact record: /a23/e?CF00NK0000001uGhj={!Account.Name}&CF00NK0000001uGhj_lkid={!Account.Id}&CF00NK0000001uGfs={!Contact.Contact_Full_Name__c}& CF00NK0000001uGfs_lkid={!Contact.Id}& 00NK0000001uHXt="Potential" However, when I use it on Production it does not work /a26/e?CF00Nb000000A16YB={!Account.Name}&CF00Nb000000A16YB_lkid={!Account.Id}&CF00Nb000000A16YA={!Contact.Contact_Full_Name__c}& CF00Nb000000A16YA_lkid={!Contact.Id}& 00Nb000000A16Yh="Potential" Could you please advise how should solve this?
    Ben McCarthy
    September 22, 2016 10:05 am
    Hey Gil, without knowing too much about this issue. It potentially could be that all ID's of the fields are different in both environments. Have you checked that?
    Gil Levy
    September 22, 2016 10:28 am
    Hi Ben, I created a button that created new custom object record from Contact record. This URL Button works perfectly on our Sandbox instance. However when I use it in our Production instance it does not work. I did make sure to change the field code and object code as indicated in Production. /a23/e?CF00NK0000001uGhj={!Account.Name}&CF00NK0000001uGhj_lkid={!Account.Id}&CF00NK0000001uGfs={!Contact.Contact_Full_Name__c}& CF00NK0000001uGfs_lkid={!Contact.Id}& 00NK0000001uHXt="Potential" Could you please advise me how could this be solved?
    Namita
    October 03, 2016 5:31 am
    Hi Ben, I could able to create such button in salesforce classic but don't see it in salesforce1 app... can you suggest something for salesforce1 app ? how shall I create a custom button for create_new_event from a account which prepopulates some account fields on event new page ? I am trying to do via creating a publisher action as visualforce page .. but its not working ! Please guide me through ! Thanks, Namita
    Fernanda
    October 03, 2016 3:44 pm
    Hi Ben how are you? I'm trying to create a clone button using this code: window.open('https://cs2.salesforce.com/{!Account.Id}/e?clone=1&00N37000005Q4b4=Inativo&00N37000005abi6=Null&00N37000005Q4ad='+cnpj+'&save=1'); I want that open a windown, with some fields changed, and already saved, but the windown that is opening is not saved, and an error appear saing that: "The page you submitted is invalid for your session. Click Save again to confirm your change." Could you help me? Thanks a lot. Fernanda Ribeiro
    Nitzan Marinov
    October 18, 2016 3:31 pm
    Hi Ben, I was just going through the steps to create the hack button and got stopped at the first step. I created the button inside my Sandbox, for my Opportunity object. chose the same settings you chose, went to the related list and couldn't see the Custom Buttons section. This means I cannot choose the button I just created. What am I missing? Thanks
    Keri Callison
    November 02, 2016 8:39 pm
    Hi Ben, What if we don't want to create a new custom button, but rather hide a Standard Button? I would love to get rid of the "New" button on the Account Tab and the "New Account" button on Account List Views. We are trying to force users to only create new accounts via Lead Conversion. Any ideas?
    Ellen Taussig
    November 09, 2016 3:56 pm
    I am having the same issue - did you figure it out?
    Asha
    November 15, 2016 3:23 pm
    Hi Ben how are you?
    Neha
    December 29, 2016 4:46 pm
    Hi, I have 2 vf pages , one is of form which will take the input from partner user, second is preview of the form shown upon clicking the preview button in first page, in second page there is button called send email , wch makes the preview as PDF and send attachementsnunte to some emails , there seems a problem while navigating from one page to other and in making pdf, in community, is it something URL break , due to site prefix , plz help . Thanks
    Cliff
    January 09, 2017 8:58 pm
    Hi Ben, Very helpful post. I had a requirement to build a button for "Log a Call" that plugged in lead information including the Company Name, Title, and Mobile Phone. This way the rep could see all the lead information on one page when calling prospects. I was wondering if you knew how to prepopulate the same information in the follow-up section of the "Log a Call" page? These fields are blank and I can't figure it out. Thanks!
    Matthew
    February 16, 2017 9:21 pm
    I created a custom button that works perfectly for me (System Administrator) but my users are having one issue. The button creates a new record for a custom object called Work Order. The button is on the related list of another custom object called Site. If there is more than one Site record with the same name, an error pops up asking the user to select the correct one. It shouldn't do this since the URL is giving both the name and the ID of the correct site. When I do it as the System Administrator, I never see this error. Is there anything you can think of as to why this only works perfectly for me and not my other users?
    Shrikant
    February 22, 2017 6:25 am
    Hello, Is it possible to prepopulate radio button with URL hack? Thanks, Shrikant
    karthik
    March 06, 2017 5:01 am
    Hi Ben, A Success Community User is trying to mimic your URL hack tutorial and having trouble with Insufficient Privilege error. Can your share your insights onto this ? Success Community Question: https://success.salesforce.com/answers?id=9063A000000DgYVQA0
    karthik
    March 07, 2017 5:44 am
    The question got resolved in success community.
    Ainslie
    March 09, 2017 11:28 pm
    Hi Ben I'm attempting to create a Formula Field using a URL hack but I'm stuck on the rtnURL part. I'm using a Custom Object "Salesforce_Event__c" and the intended process is to update the current record (which works fine), then, on SAVE, return to the same record but it just isn't working (the error says "URL No Longer Exists" and he browser shows "https://cs5.salesforce.com/SFDC_Attendence__c.Id" instead of returning me to my record. FORMULA FIELD (Text) IF(TEXT( Status__c )'Attended', HYPERLINK(Id&"/e?&00N20000000seJc=Attended&retURL=/{!SFDC_Attendence__c.Id}", "Mark Attended"),"Checked In") Hope this is something really simple to fix. Thanks, AB
    Michelle
    March 28, 2017 8:59 pm
    THANK YOU SOOOOO MUCH! I have been working on a custom button all day and I found this article at the very last minute. Thank you for helping me solve this right at the buzzer!
    dhanu
    April 14, 2017 12:51 am
    Hi, i need to pre populate the Accuont name in case object if click new case(custom Javascript button) on account page.if i click on new case button it is redirectring to record type selection page after i selecting the record type record type it is going to the record creation page .here instead of account name it is populating {!account.name} as a string, which i am passing from js button
    Joan Jackson
    April 25, 2017 2:37 pm
    Hi Ben, thanks for this post. We have a custom javascript button on case that opens a task record and auto-populates certain information from the task into the case. It works fine on a normal Salesforce page, but people in our call center use the Service Cloud Console to access this custom button on a case. Lately when they use this button, they keep getting the "The action your performed is invalid for your session" error. Part of the javascript behind the custom button determines whether the user is in the console, and if so, the url for the Task window begins with var url = window.parent.location.href = "/00T/e ..." and the rest. Since the URL from within the console looks like this https://na42.salesforce.com/console?tsid= instead of this https://na42.salesforce.com/ I am wondering if there is anything I must do differently to create the Task URL when a user is creating it from within the console.
    Joan Jackson
    April 25, 2017 2:38 pm
    Oops, I meant certain information from the case auto-populates into the task. Sorry for the confusion.
    Jay
    May 10, 2017 2:15 pm
    Can I update a checkbox in the Send an email URL? I've actually passed the field ID (00Nm0000001CX8y=1) in the URL but it didn't work!! location.replace('/email/author/emailauthor.jsp?retURL=/{!Opportunity.Id}&p3_lkid={!Opportunity.Id}&p2_lkid=003m000000YHZR6&rtype=003&00Nm0000001CX8y=1&save=1&template_id=00X60000002u9yq&p5=');
    Mimou
    May 17, 2017 4:45 pm
    Hi Ben How did you manage to find this id please ? I cannot find it in the code. Thanks
    Shaik
    May 18, 2017 1:30 pm
    I am facing issue with passing parameters to a web tab(External Application configured as Web Tab). The Web tab functionality is it will show the details of the record id which we pass the parameter from salesforce. I have created a custom URL link and i am passing parameter to call the Web Tab. I am able to land on the web tab but its not diplaying the data which i am requesting as alsways after web tab launch its loading the web tab from URL defined in the webtab. Please let me know is there any other approch to pass the dynamic parameter to a wab tab. Thank you, Shaik
    Eli
    June 07, 2017 12:32 pm
    Do you have a solution for Lightning? I believe URL hacking does not work in Lightning. It would be a good idea to have an alternate process for Lightning.
    Nelson Rodriguez
    June 07, 2017 8:19 pm
    I need to use a file URL like the following: file://abc.corp.com/f67b52dcf0d1_myFile.jpg When I put it in a URL field and click on it, the field tries to add in front the HTTP:// making the link unusable. Is there anyway to make this work as a link or button. As long as it works. Any help will be appreciated!
    Amit
    July 19, 2017 11:14 am
    Thanks for the info.. it helped.
    Chethan
    July 25, 2017 12:01 pm
    Hi Ben, I have a requirement where i have to pre-populate the Account name field which is mandatory while i am creating an contact. I am not creating the contact under related list of account. I am directly tapping the contact tab and then creating new one.This one is for Lightning. My first preference would be configurations. Let me tell you why , i have to integrate this with gmail. So, i don't think code will work well in that case. When the User create the contact in Gmail, Account has to be pre populated there. So, Please do tell me a way to achieve this. Thanks and Regards, Chethan.S.N
    veergupta
    September 05, 2017 7:19 am
    I'm so glad i really like your post thank you.
    Mike Livingston
    September 12, 2017 3:01 pm
    Gil, I'm wondering if you ever resolved this? I'm working with a client that has the exact same issue. Thanks!
    Marjut
    September 21, 2017 12:45 pm
    How would I pre-populate opportunity CloseDate a month from today?
    Kruse Collins
    October 03, 2017 10:41 pm
    Great post Ben, it completely taught me how to do the basics of this without previous knowledge. Great tutorial, thank you!
    Vincent Bartoloma
    October 25, 2017 4:01 am
    Ben - this was a really great post. Thank you very much. One question : How do I populate a lookup field with the value of a lookup field in the parent ? In your example you referenced the parent's ID & Name. I would like to reference a custom lookup on the parent to fill a child's lookup field. I'm confused because I can't just use Opportunity.Customlookup__c - can I ? I would have to somehow get the ID and Name of the record in the Customlookup__c field. Is this one of the cases where I would instead reference formula fields on the Oppt which contain the ID and Name of the record in the Customlookup__c field ?
    Ryan T.
    November 21, 2017 11:18 pm
    Ben (or anyone reading this), do you know if this technique will work with grabbing data from External Objects? We are pulling data from an external system/database into Salesforce, in a read-only fashion. That means the data resides in the external system, and any searches result in the top 100 returned records. These returned records are temporarily stored in the external object Item_Master__x. So I can open one of the records and the 8 fields of item detail information are all populated with data. One of which is the manufacturer's code: MANUF_CODE__c I can successfully query the object and all fields in it using SOQL, including the MANUF_CODE__c field. However, when I create a custom button in this external object that references the field {!Item_Master__x.MANUF_CODE__c} the following error message is returned: Error: Field Item_Master__x.MANUF_CODE__c does not exist. Check spelling. I'm lost. Any help would be appreciated.
    Rafi
    December 04, 2017 7:16 am
    Hi Ben, I have a requirement to open a new record as subtab of case inside a console by clicking on feed post link. Whenever I clicking on link in the feed post it is opening in a new browser window. But it should open in a same browser window as new sub tab of case record. The url is like below. Please help me to achieve this. https://hp--gsddev12--c.cs13.visual.force.com/apex/GSDCSCCVSResultsPage?id=5002700000hNN4P Thanks, Rafi
    Manish Kumar
    January 05, 2018 8:33 am
    Hi Ben, Can you please help me out create URL hack for lightning view. I have pre populate "Account Name" field with the Account Name Of current logged in Community User. Community User's have only Lightning View access. Thanks in Advance for helping me!!!
    Patrick
    January 15, 2018 3:30 pm
    Hey Ben, I have a question reguarding to your tutorial. Is it both needed, the "CF00Ni000000EpsgO={!Opportunity.Name}" & "CF00Ni000000EpsgO_lkid={!Opportunity.Id}" or is one of the parts enough? I am building a custom button for a custom object related to the standard contact object. If I just use the first URL Hack (&CF00N0Y00000Oog8l={!Contact.Name} - accordingly the same with Account Lookup) it works, if I just use the 2nd hack (&CF00N0Y00000Oog8l_lkid={!Contact.Id} - again the same with Account) it dont work. If I use both it works the same way as 1st version and all field are populated in the URL. So do I need both parts and if yes, why? Thanks, especially for the tutorial Kind regards
    Jonathan
    January 17, 2018 6:04 pm
    How does this URL process change for multi-picklists? I have not been able to get multiple values to pre-populate in the carry over fields. How do I ensure that this happens depending on which values they select from the lists?
    Rajni
    March 05, 2018 11:53 am
    can we pass link under piclist values
    Daniel Rich
    March 21, 2018 1:15 am
    Hi Ben--terrific post. A question about the following please: If you have multiple record types, you can easily pass in the ID of the record type using this format – &RecordType=abc. With abc being a fixed value or possibly a merge field with your Record Type ID (This can be found on the record type page). **I need to pass a Record Type (pickval) from the Master to the detail object. It hards codes fine with the URL hack, but I ned to pass the variable such that DetailRECORDTYPE=MasterRECORDTYPE. Thoughts please? Thanks.
    Barbara
    April 02, 2018 7:57 pm
    working through this and its great - thanks just one question - there seems to be some functionality loss doing this in a playground - ie I can't seem to customise the button for the layout?
    Rovan Renato Monteiro
    May 12, 2018 12:06 pm
    Hi, I would need your help to know how do we create a custom URL to a case record by referencing a custom field in that case object (which is unique just like the case ID), so when the click on the URL they are taken to that record.
    Pascaline
    May 15, 2018 2:06 pm
    Hi, Thanks for sharing that, works like a charm :-) I have a little problem though, hope you can help me out: With your URL creation Tutorial I have now a Button creating a Custom Task Record Type with prefilled WhatId ( what_id={!Case.Id} ) and WhoId (who_id={!Case.ContactId} ) My users need to also have the Account displayed in the Case, and I just can't find a way to have the URL pre-filling as well. I also just don't have any "AccountId" in the Task/Activities fields, so I created a Custom Field with type Lookup(Account) and tried to fill it with ={!Case.AccountId} but the field just remains blank, any idea whatI'm doing wrong ? Thanks :-)
    Dan Prior
    June 13, 2018 6:10 am
    Hi, I have a two objects (Control, Action) linked by a junction object. On the control object the related list for the junction object is showing and I have placed the New Action button with the URL hack on the related list. This all works fine and the Action record is created but I cannot get the record on the junction object created. Is this possible in the URL hack? Thanks, Dan
    Dinesh
    July 02, 2018 6:51 am
    I have a doubt on how to update a read-only field on the Page layout by passing the value from URL? Consider, I have a read-only field named X added on the layout. I want to pre-populate this field value from URL. Please suggest me with any solutions. Thanks, Dinesh
    David Lau
    July 16, 2018 8:31 am
    Hi, I have created a custom button to create a new record when activated. I wanted to pre-populate some data to the new record using the url hacking I have read from this website. I have use the below url for the custom button. /a03/e?CFCF00N2800000Ik9ks = {!QAF__c.Account__c} & CFCF00N2800000Ik9ks_lkid = {!QAF__c.AccountId__c} & 00N2800000GqRYf = 1 &retURL={!QAF__c.Id} When the button is activated, the new record was created but the values are not pass onto the fields. I have checked the field id and they are correct. I can see that the data is pulled from my QAF record (where I launch the button) on the top of the url field. The data is just not filling into the record. I think it should be a simple or stupid error that I am not seeing. Can anyone please help? Thanks, David
    Ann Gately
    July 26, 2018 12:22 am
    Ben thanks for the tutorial this is the first time I have ever had to reach out, normally as soon as I find one of your tutorials I am all set, but not today ☹. I am having the same issue David is having I created the below button but only the text field is populating. I am not sure what I am doing wrong. I am trying to create a custom button on the Campaign Member object to create an opportunity and auto populate the account name and several other lookup fields, but I cannot get the first look up field to work so I have not moved on to the others. /006/e?opp3=Any Value &CFopp4={!CampaignMember.Primary_Account__c}&=CFopp4_lkid={!CampaignMember.Primary_AccountId__c} Any help would be very appreciated, Ann Gately
    Linda Thompson
    July 31, 2018 12:01 am
    Hello- I'm trying to make this work in Lightning and the button is not showing up. Here's the URL I constructed: /00T/e?RecordType=01236000000yUx1AAE&cftsk3={!Program__c.Name} Does this not work for Lightning? Thanks for your help!
    Praveena Gavini
    July 31, 2018 1:22 am
    We have an org that has a lot of buttons using this hack. Now that we want to move to lightning, how do I get a list of all these buttons and wherever they have been used in this org? Is there a way to quickly find them all and list them as buttons that need to be transitioned to lightning?
    yupoo china
    October 19, 2018 11:48 am
    Hiya very cool website!! Man .. Beautiful .. Superb .. I will bookmark your web site and take the feeds also? I'm happy to seek out a lot of useful information right here within the post, we'd like work out more techniques on this regard, thank you for sharing. . . . . .
    Eve Hunt
    October 22, 2018 10:04 am
    It seems like the deep web is a web space that only you people can utilize. How can this help the ordinary citizen who seem have little chance of benefiting when using the deep web. you have shown that the deep web is very bad, yet it can be useful. How can the deep web be utilized to such an effect as to help people in organizing and building resistance against evil things in this world such as government and the darkness that permeate the deep web and this world? please shed some light into the darkness by answering this question. THANK YOU
    payless grocery ad
    October 29, 2018 4:54 am
    This website really has all the information and facts I wanted about this subject and didn't know who to ask.
    sunglasses store ray ban
    October 30, 2018 9:37 pm
    Quality articles or reviews is the crucial to invite the visitors to go to see the site, that's what this web site is providing.
    Merchant Fee's No More
    November 02, 2018 9:14 am
    I am truly glad to glance at this weblog posts which carries tons of helpful information, thanks for providing such statistics.
    Tom
    November 13, 2018 11:16 am
    Hi Ben, thanks for the great tutorial. Have you been able to replicate URL hacking in Lightning?
    Cesar
    November 15, 2018 10:22 pm
    First off I would like to say terrific blog! I had a quick question which I'd like to ask if you do not mind. I was curious to find out how you center yourself and clear your thoughts prior to writing. I've had a tough time clearing my thoughts in getting my ideas out. I do take pleasure in writing however it just seems like the first 10 to 15 minutes are wasted simply just trying to figure out how to begin. Any recommendations or tips? Cheers!
    SwarnaLatha
    November 20, 2018 6:17 am
    Fernanda, I've the same issue, did you figure it out?
    Christophe
    February 21, 2019 12:34 pm
    Also looking Lightning URL hacking! Anyone please.
    jane oliver
    June 05, 2019 11:00 am
    Very well written and informative post. Just what i needed. Thanks ben
    Eric Ishikawa
    July 03, 2019 3:35 pm
    opp9={!ADDMONTHS( TODAY() ,1)}
    Silabarasan
    October 23, 2019 8:25 pm
    Hi, html input id will different one sandbox to another one? i have seeing the difference. don't know how to tackle. Thank you
    Matt Hammel
    October 24, 2019 1:01 am
    I have created a custom button that creates a custom object. It is on the custom object related list on the Contact page layout. Therefore, the retURL I am using is retURL=%2F{!Contact.Id} I want to reuse that same button on all the standard objects. Is there a way to make the retURL code dynamic? I see that I can use the if function or the case function. I was thinking if I could look at the ID that the record is created from, I could use something like: IF( id of the object this custom object was created from starts with 001, retURL=%2F{!Account.Id}, etc... Any thoughts?
    Pete
    November 12, 2019 2:16 pm
    I had a blast reading this Ben, thank so much buddy!
    Raven
    February 04, 2020 4:01 pm
    Ben, I am dying here. I have a custom button on a custom object. I want some of the info from that custom object to populate a new contact form when the button is clicked. I see the data that should be passed in the URL but nothing appears in the edit form. Wisdom??? Also, can I launch a new record form from Process Builder for this? I am seeing online that it is not possible. That Apex is necessary. Thanks.
    Naresh
    May 28, 2020 7:00 pm
    Thanks this is very nice aticle and i am always confuse :). I have a question is the url hacking to prepoulate values on feild will it work for VF pages too. Example: 1) Custom buttong is handling some logic 2)Then invoking VF page with Opty ID 3) 2 + field with preopopulate value -> works. Please help , I tried this but getting error as Opty standard page Error: Id value is not valid for the Opportunity standard controller
    Akash
    August 25, 2020 2:53 pm
    Hi, I want to pass custom field value into custom link url in SFDC. Custom field is 'travelId'. From record travelId could be 78878 Actual url: https://apidata.mycompany.org/standard/v1/78878?Subscription-Key=yugh58f387hygf59b6e12a3571ygyu87 To have Dynamic url: In custom link I tried with https://apidata.mycompany.org/standard/v1/{!Travel__c.travelId}?Subscription-Key=yugh58f387hygf59b6e12a3571ygyu87 It is not working.
    Ronaldo Costa
    September 12, 2020 6:51 pm
    Hello, did you find the answer? I'm going through the very same issue here. read-only fashion doesn't help us at all.
    Nithya
    November 06, 2020 11:33 am
    I have a object A which has Master- Detail relationship with Object B. How can I pass Object B record Id in retURL?
    Shweta
    October 28, 2021 8:28 am
    I have created a new custom button of detail page button. Contact object has two record types : Professional,Personal By default its redirecting to Professional record type. However i want only Personal record type to get selected. Where can i do the change in url to select only Personal record type? /lightning/o/contact__c/new?defaultFieldValues=Name__c={!contact__c.Name__c}, Address__c={!contact__c.Address__c}, Country__c={!contact__c.Country__c}, Occupation__c={!contact__c.Occupation__c} Where to include RecordType.DeveloperName='Personal_Plan' or RecordTypeId='Personal_Plan' in url ? Please help me out with this. Thanks
    saimohan
    November 24, 2021 4:34 am
    can we try this in new lead screen is it possible
    manikanth
    January 20, 2022 2:47 pm
    hi i have created the button but it is going to classic not lightning url :/lead/leadconvert.jsp?retURL=%2F{!Lead.Id}&id={!Lead.Id}&nooppti=1 this is url i have used in button any suggest how to redirect to lightning convert button
    Vinay
    March 08, 2022 5:32 am
    I have created URL button below this URL i'm using /lightning/o/License_details__c/new? backgroundContext=/lightning/r/Account/{!Account.Id}/view &&recordTypeId=012c0000000EreJAAS -----> Here I don't want to Pass RecordtypeId i want to pass by record type name. &defaultFieldValues= Brokerage__c={!Account.Id} How to give recordtype name in URL/ any other way to do this without giving recordtypeId. Any solution on this.?? Thanks in advance
    Vinay
    March 08, 2022 7:15 am
    I have same issue. can you please share how did u overcome this issue.
    Tabea
    July 11, 2024 9:19 am
    Hi, is there a way to create a custom button that creates a new opportunity but sets a default value for opportunity stage but still allows the user to select which record type? I have created this: {!URLFOR('/lightning/o/Opportunity/new?defaultFieldValues=StageName=Discovery')} But it always creates a new opportunity using the default record type. I want the user to choose which record type they want.

Leave a Reply