4 Clever URL Hacks – Salesforce Custom Buttons

Share this article...


Salesforce custom buttons can remain a bit of a mystery to Administrators that haven’t used them before. But you might be surprised that Custom Buttons can do a lot more for you than you might think.

Salesforce custom buttons can be used to launch webpages with customised data from the record you are currently working on. These webpages could be external webpages such as Google or Salesforce pages such as Accounts, Contacts or Reports. This allows us to make shortcuts in our work, taking information from a record we are currently working off and populating it in another web page. Below I’m going to be talking about 4 areas where salesforce custom buttons can be used to save your users time carrying out certain tasks.

As a word of warning, the reason these are considered “Hacks” is because Salesforce do not support them.

Pre-populating new Records in Salesforce (URL Hacking)

One of the biggest use cases for custom buttons is a technique called URL hacking. URL hacking has been around in the Salesforce world for a while and is the process of pre-populating a new record with information from a previous record. As an example, lets say after an Opportunity is closed won, a request has to be sent to a certain department detailing next steps for this deal.

Lets say that this Resource Request object has a lookup relationship to the opportunity and when a sales user has closed the deal, he will look to this related list to create a new resource request. Without any type of process involved this will require the user to enter all details manually on the next page, which seems a bit redundant if some of the details are on the opportunity readily available?

Screen Shot 2015-02-06 at 15.26.52

Check out my comprehensive URL Hacking Tutorial here!

Sending an email with pre populated information

Just like URL hacking above. The email page on Salesforce is just that, another page. This means with custom buttons we can manipulate what gets pre-populated on this page. If you find your Sales/Service users sending repetitive emails like Lead Qualification or Introduction emails, then using this technique will mean fields like To, From, Subject and Body (Using Email Templates), BCC, CC can all be pre filled so all the user has to do is edit accordingly and send!

 Check out how to URL hack the Email page here!

Screen Shot 2015-02-08 at 15.07.04

Launching reports with custom information inserted.

So the message you’re probably getting from these tutorials is that Salesforce pages can be manipulated via the URL to display custom information. Surprise surprise! Salesforce reports are no different. We can actually build buttons or links on records to launch reports and insert custom information from these records.

Let’s say you have a few large accounts and managers regularly check the progress of current open opportunities of these accounts. You have a few options..

1. Create a report per account.
2. Create one report and change the name each time.

OR create one report, link this to the account, and use merge fields and URL hacking to populate this information automatically!

Check out how to hack the Reports page here!

Launching External Websites with Custom Information

So far we’ve covered launching internal Salesforce pages. But did you know you can actually launch any webpage you like and insert something custom? Quite a popular use case is a tracking number for a parcel. Lets say you insert all your parcel tracking numbers into Salesforce and find yourself copying them out of Salesforce and into the parcel couriers system. The data is already there so why bother copying it out?!

Similarly to my other hacks, you just need to paste in the URL and place a merge field where you would like the data inserted. For example if you used fedex you can expect the URL to look like this.


How did I know where to get the FedEx URL from? I just went on their website, entered a tracking number and looked at the URL!

Screen Shot 2015-02-09 at 14.24.41

Hopefully you’ve enjoyed this article. Let me know how you got on, if you have any questions and if you have any other use cases!

13 thoughts on “4 Clever URL Hacks – Salesforce Custom Buttons

  1. Great article on URL hacks. I have one that I cannot figure out, though. I want to create a new custom button to replace the standard “New” button on Leads. This button will pre-populate the Lead “Website” field with the domain that the user entered on the “email” field. I don’t want the “website” field to display on the initial record creation if possible, because it gets pre-populated and I don’t want users typing in data.

    For example, if the new Lead has an email of “[email protected]”, then the “website” field will be “www.xyz.com”. They can edit it after the new Lead is created.

    I cannot seem to figure out how to get a ‘partial’ data field like this. If you have any guidance it would be most appreciated.

    1. Hi Jeff, thanks a lot. I’m not entirely sure this is possible? As URL Hacking is meant to pre-populate data on a new record from a previous record you are on. But as this is a new record, there is no data to populate. I think you might be looking at a little APEX trigger to do this. Would be interested to hear your thoughts.

      1. Hi there,

        Sounds like it might be a workflow field update that happens after the record is created? There are ways you could omit the website field from the lead record on initial creation (e.g get users to use an action to create a lead or there are other ways), but I think you could probably just leave it on the layout, then have a workflow rule that populates that field on record creation if it has been left blank.

        Alternatively, if you don’t want to leave the website field blank as you think users might enter something you can use the URL hack to prepopulate it with something like http://www.example.com then use workflow to update it to the correct value.

  2. One of the negative things around URL hacks is that they are not supported in Salesforce1 thats why Salesforce invented “Actions”. ALWAYS before you want to start doing a URL hack ask the question “Can this be achieved by an Action?”. If it can do it via an Action as then it will support Salesforce1 mobile users.

    My 2 cents worth 🙂

  3. I have used URL hacks for a couple of buttons. Typically they work great. Although I am having trouble getting one to work with a Rich Text field. Both the originating field and destination field are Rich Text fields. Do you know of any issues with the URL hack with Rich Text fields?

  4. The problem I have with Actions is when it comes to prepopulating a picklist field, you have to define a specific value where with a URL Hack you can capture the value from related record. I’m hoping Salesforce will eventual address this limitation.

  5. Hi, when clicking the button that leads to the external url is there any possibility that the warning message asking if you want to quit Salesforce does not come out?

  6. Robert Edwards



    How do you pre-populate a lookup relationship field on a standard object that looks to a custom object with a custom url button so that the 2 records are automatically related?

    Case in point is I am creating new Opportunity records via a custom url button on the Subscriptions object. I also have a lookup relationship on my Opportunity object named Related Subscription (Related_Subscription__c).

    I was also wanting to automatically fill in the Primary Bill To Contact (another lookup field to the Contact object with the Contact that is affiliated with the individual subscription being renewed. I have tried passing the text values to to those fields, but they will not populate.

    Any insight here?

  7. Hi Ben,
    We have a button on case object that we want to use as hyperlink on Account object so when a user clicks that link, it will create a case just like when he/clicks on the button:
    This is the button:


    var caseObj = new sforce.SObject(“Case”);
    caseObj.AccountId = ‘{!Account.Id}’;
    caseObj.RecordTypeId = ‘0123E0000008WLT’;
    caseObj.Type = ‘Complaint’;
    caseObj.Is_Complaint_Checkbox__c = true;
    caseObj.Priority = ‘Is Complaint’;
    caseObj.Subject = ”;
    caseObj.Description = ”;

    var result = sforce.connection.create([caseObj]);

    window.location = “/” + result[0].id ;
    alert(‘Could not create record ‘+result);

  8. Just thought I’d share this info for anyone trying to use FedEx, the original URL is no longer accessible (https://www.fedexuk.net/accounts/QuickTrack.aspx?consignment=) however after some digging and with ZERO help from FedEx themselves I have found the following URL works just fine – https://www.fedex.com/apps/fedextrack/?tracknumbers= just add the consignment number(s) to the end of the URL. Yes, you read correctly, you can add a comma-separated list of consignment numbers too. Happy tracking.

Add Comment