04 March 2014

Auto-magical things you can do with salesforce links

Ever notice how the URL in the address bar of your browser can be used to do auto-magical things in the app? 

I've been spending a lot of time in the logs looking at URLs and having to interpret what the links actually mean. But understanding the salesforce link structure opens many different doors for an admin including creating custom links, passing parameters into pages and reports, creating formula fields, bookmarking, and other general hackery.  

Below are tips and tricks to master the salesforce URL link structure. Most of the following is from Travis Bryant and Keith Torluemke who put together an incredible tip sheet that I've edited here.

All the links listed here will only work if the user has already logged in to salesforce, and the valid session id is stored as a cookie. If there is no session id, these links will not be accessible and the user will be directed to the login page.

All URLs accessed for salesforce will start with the structure https://<server>.salesforce.com/, where <server> is the particular instance of the salesforce service that the customer's organization is hosted on. For a full list of servers, you can take a look at the salesforce trust site. Example values for <server> include:

  • na1
  • na2
  • na3
  • na4
  • ap
  • emea

You can also have a custom domain name like https://salesforcehacker.my.salesforce.com using the My Domain feature. Otherwise, the first part of the address will typically be the server where your org resides.

When creating a link that will be used within the application, for instance as a Custom Link, the https://<server>.salesforce.com is not needed. All that is necessary is a relative URL which starts with a "/", as in "/015300000007epj" which could be used to access a particular record.

The next part of the URL will typically reference an object type by key prefix, such as Accounts, Contacts, Opportunities, etc... Some common object key prefixes include:

  • 001 - Accounts
  • 003 - Contacts
  • 006 - Opportunities
  • 015 - Documents
  • 500 - Cases
  • 00O - Reports
  • 00Q - Leads
  • 01Z - Dashboards
  • 701 - Campaigns

Standard objects have object key prefixes that are consistent across orgs. Custom objects have a key prefix as well, but it is based on a particular org implementation, thus custom links would most likely break upon sharing between orgs. The easiest way you can obtain a key prefix is by performing a describeSObject() on the particular object using the API (i.e. using Workbench) or with the .getKeyPrefix() method in Apex.

View Links

These URLs are used to view various screens within the application

Relative URL
App Home Page
Go to the overall home
https://na1.salesforce.com/home/home.jsp (Homepage)
View Object Home Page (Tab)
Go to the homepage for the object’s tab
/<object key prefix>
https://na1.salesforce.com/001/o (Account Home Page)
View All Objects
Go to the last list view for that object
/<object key prefix>
https://na1.salesforce.com/003 (View Contacts)
View Object/Record
Open an individual record’s detail page
(Individual Account)
Download Doc
Download a file from the doc tab
*Download Content
Download a file from Chatter Files
Mini-Page Layout View
See a minimalist view of the record
Print View
Print a page

* - When downloading content, multiple files can be downloaded as a zip. Use this syntax:


where ContentVersion ids are separated by forward slash. (Hack from crop1645 in comments below)
Edit Links

These links are used to go to edit object screens (new, edit, clone, or add related task).

Relative URL
Create New Object/Record
Go to the new record screen for that object
/<object key prefix>/e?retURL=<PreviousURL>
Edit Object/Record
Go to the edit record screen for a specific object/record
Clone Object/Record
Go to the clone record screen for that object/record
Add a Related Task
Schedule a task associated to a particular object/record
/<object key prefix>/e?retURL=<PreviousURL>&what_id=<id>
Transfer a Record
Transfer Ownership (affects sharing)

Link Structure Key:
  • <server> - Name of the salesforce instance (e.g. na1, na2, ap, emea, etc…)
  • <object key prefix> - The key prefix of the type of object (e.g. 001, 003, 005)
  • <id> - unique record id of the particular record or object including key prefix and server identification
  • <PreviousURL> - this is the relative (meaning, starting with “/” instead of the fully qualified domain name “https://na1.salesforce.com”) URL of where you’d like to return after completing the edit. This could be any of the View Links listed above. If the return link is not included, salesforce returns the homepage. Note: the use of “%2F” is code for the character “/”, which is needed to create the return link correctly.
  • what_id - this is the id that the task should be associated to, whether Account, Contact, Opportunity, etc…

Creating New Objects and Pre-Populating Fields

Using one of the Edit Links listed above, a custom link can be created which pulls data from a record and populates another record. For example, a custom link can be created from an Account page which creates a case and pre-populates some of the case fields with data from the Account record.

Relative URL
/<object key prefix>/e?retURL=<PreviousURL>&<field id1>=<value>&<field...>

Link Structure Key:
  • <object key prefix> - The key prefix of the type of object (e.g. 001, 003, 005)
  • <field id1> - this is the identifier of the field in the html of the Edit object page. To get this id, View Source of the edit object page, and search on the Field Label. The control (radio button, check box, select box, etc…) will have an id attribute. The value for this id attribute is what you need to add to the custom link. Note: be careful when viewing the source of a page as salesforce reserves the right to change the page attributes in future releases which can break automation built around those attributes.
  • <value> - this is the value you will pass into the field. This could be a literal value (e.g. “1” or “High”), or a merge field from the record you’re coming from (e.g. {!Account_Customer_Priority}).

Passing Parameters to a Report

Using a custom link, a user can launch to a report and pass parameters to make the report unique.

Relative URL
/<report object id>?pv0=<par1value>&pv1=<par2value>&pv2...

Link Structure Key:
  • <report object id> - id of the specific report to run
  • pv0 - list each parameter passed to the report (e.g. pv0, pv1, pv2, etc…)
  • <par1value> - specific value for the parameter, which could be a merge field (e.g. {!Account_Name}).

Understanding the salesforce URL link structure can open doors to salesforce customizations. Don't be afraid to experiment and let me know how it goes! Happy linking!!


  1. You can also get to tasks and events in a list view format by using /00T after your org url. Example https://na14.salesforce.com/00T

  2. Going to /one/one.app will take you into Salesforce1.

  3. Regarding pre-populating fields on a 'New' page, this isn't officially supported by Salesforce (as it treats the UI as an API) and could change in ways that'll break an implementation. Having said that, there's no currently suggested alternative and if you can live with this possibility, hack away!

    See the response on this idea for more information: https://success.salesforce.com/ideaView?id=08730000000gM7mAAE

    1. Definitely agree - salesforce won't support anything that is hacked in the DOM. That's part of the fun! Develop with care and consideration!!

  4. Just found another list of uri mappings:

    Standard object based pages:

    /d: Detail- Detailing a single record and with its associated records
    /m: Hover- HoverDetail page that uses a mini layout and no header/footer
    /e: editPage Allowing the editing of a single record
    /p: printableView- In a relatively unadorned format, detailing a single record and all of its associated records. Does not have a help link, since you can't click links on paper.
    /o: Overview of a single entity.
    /l: list- A filtered list of a single entity
    /x: Printable list: A filtered list of a single entity. Does not have a help link, since you can't click links on paper.
    /r: Refresh list: A stripped down version of a list filtered by ids
    /s: special: Special is used for "other" pages where you want to reuse parts of the edit/detail page
    /h: history: Show the history (used only in forecasting)
    /a: Assign: Entity Owner Change page
    /c: calendar: Time-based (Calendar) view of list data
    /n: mini edit: Mini layout edit page

    Custom Objects based Pages

    /d: Detail
    /m: Hover
    /e : Edit
    /p: Printable View
    /o: Overview
    /l: List
    /x: Printable List
    /a: Assign
    /r: Refresh List

  5. In the category of Reports URLs, don't forget "pc" and "pn" to use with "pv".

    pc0 for the first field
    pn0 for the first operator
    pv0 for the first value

    Operator values are eq, ne, lt, le, gt, ge, co, nc, sw and in

  6. Any ideas how to hack a related list? So for example, i have a contact John Smith, who has a related list called 'Associations' he is part of A, B & C associations, i want to create a report that shows all the other contacts part of A B & C to be called from a button on Johns Contact page. How do i incorporate the related list details? Thanks Julie

    1. Hi Julie,

      Hacking a related list from a URL hack and not really recommended from a screen scraping standpoint. If you're traversing relationships between objects including records that may be off-screen (A, B, C, D, E, and F are available but G, H, I, J, K, and L are not visible on the screen but valid associations), you really should consider Apex instead of pushing the URL hack imho...

  7. Hello - When passing parameters into a report. Is there anyway to conditionally pass the parameters so that they only populate if the specific field on the SFDC object is populated?

    IE I have 4 fields. The first 2 will always be populated. 3 and 4 might not be populated. I only want to pass values from 3 and 4 into the report if they are populated. Can I use an IF statement (or something similar) in the link to conditionally pass parameters into the report Report (based on the field being populated)? Or any other trick to do this?


  8. Sorry not sure if the above is clear enough.

    To be clear I only want to include fields 3 and 4 in the filter criteria of the report if they are populated. Currently if they are blank the report is not exactly correct because it only pulls records where Fields 3 and 4 are null. If the fields are null on the object I would like to not include them in the report criteria.

    Is this possible?


    1. I don't think this is possible but I'll do some digging.

    2. Hey thanks for the reply Adam. I think I actually got it to work with a nested if statement that spits out the correct report ID. I did have to create one report for each scenario (of fields that are populated) but I think I got it working. As long as the report does not include pv5 for example then the link can not try to pass anything into that filter. Syntax Below. Good times!

      /{!IF(ISPICKVAL(Reference_Request__c.X2nd_Priority_Talking_Point__c,'')&&(ISPICKVAL( Reference_Request__c.X3rd_Priority_Talking_Point__c,'')),'00Oe0000000GoHV',IF(ISPICKVAL(Reference_Request__c.X3rd_Priority_Talking_Point__c,''),'00Oe0000000GoHG', '00Oa0000008eyO7'))}

  9. Hi Adam, thanks for this page.

    How would you pass a parameter for the print url in visualforce?
    For example I have custom list page in VF that I want to display a printable view link for -

  10. Hi Adam, thanks for this page.

    How would you pass a parameter for the print url in visualforce?
    For example I have custom list page in VF that I want to display a printable view link for -

    1. https://developer.salesforce.com/page/Visualforce_Extended_Print_Preview

  11. Hi Adam,
    I would like to Edit the Task
    Can you Post me URL to Edit the Task

  12. Hi, Is it possible when sharing a link to a file on Salesforce that the file auto opens/plays instead of asking the user to download?

    1. Hi Tammy,

      Thanks for reading the blog!

      There is a preview function for certain file types like powerpoint and PDF. However, if the file extension is questionable or unknown, you only get the prompt to download I believe.



  13. Adam, you can add to the table under Download Content that multiple files can be downloaded as a zip. Use this syntax:


    That is, ContentVersion ids separated by forward slash. I've tested this and been able to get some pretty big zip files before I got tired of waiting for a response (~400 MB)

  14. p/share/AccSharingDetail?parentId= will give you the visibility reason of a record in case you get a permission denied error.

  15. I'm looking for ID= as described and I'm finding things that are different from what is above. For example, if I look at a field on two contact records I see ID=
    ...which are not consistent and don't fit the pattern above.

    Am I looking at the wrong ID or what?

    Thanks... Bob

  16. Hi there ! Great content...
    Anyone succeeded in Hacking URL to filter a dashboard ?
    Have a dashboard that can be filtered ... but hit the limit of number of filter values, was hoping we could hack the url to pass the filters as parameters... Anyone ? Thanks

    1. I've never seen that done I'd be curious to find out if someone figured out how to do it

  17. can anybody help me how to pass parameter to chatter tab? Actually I want to open chatter tab from custom button on contact record. I know how to do that. But I also want message input box to be auto-populated with @mention tag from parameter.


Note: Only a member of this blog may post a comment.