+ Start a Discussion

Custom Object New Button URL

It is easy to construct the URL for a new button for one of the standard objects:



For custom objects, the URL uses an Id (prefix 01I) in place of "Opportunity" in the above example. I haven't been able to determine if there is any way to get the corresponding Id for a custom object in order to generate this link. Replacing the Id with the object name or API name doesn't work. I've also tried using URLFOR with the Weblink object, which doesn't work. Has anyone done this or have any ideas?



Best Answer chosen by Admin (Salesforce Developers) 
Prafull G.Prafull G.

All Answers

Prafull G.Prafull G.

Thats correct. Custom Buttons and Links uses 3 parameters 

type, setupid and PageOrSobjectType


For Standard Objects all of the parameters uses names as they will never change across different orgs. However for custom objects these are replaced with Object Ids. What you have to do is

1. Identify the object id (Click on the object then check the URL you will see ID starts with 01I)

2. type and PageOrSobjectType will be the custom object id (identified in above step)

3. replace setupid as CustomObjects


then you have to construct the URL as



Please not the setupid will remain same for all custom objects i.e. CustomObjects


NOTE: One more thing, the url you mentioned has retURL parameters which makes the URL too long. You can specify the return url as per your need.


Hope it helps.



Yes, it is super easy to get that URL manually. I should have been more specific. I want to do this dynamically, not manually. There is no way that I can find to query for the Object Id for this URL. It doesn't even look like I can get this from the Metadata API.

Prafull G.Prafull G.
This was selected as the best answer

Thanks, Prafull!!


I was hoping I wouldn't have to do it that way, but it seems to be the only option.