I am building an application that I hope to sell on the AppExchange. On that application, I am building three custom "new record" buttons on a related list (parent and child objects are both custom objects) -- one for each Record Type on the child object.

I have successfully used URL custom buttons to pass Record Type ID via a URL parameter; however, the URL parameter is the Record Type ID (as opposed to Name), which will change with each organization. Since this will be an AppExchange application, it must be dynamic.

I have decided to create a Custom Setting that holds the Record Type IDs for each Record Type; however, I do not know how to dynamically determine the Record Type IDs within the Custom Setting. I do not believe I can use SOQL or other Apex code to retrieve these dynamically, but I could be wrong.

So my two questions are: 1) What is the best method for determining Record Type IDs dynamically? 2) How do I update a Custom Setting with that ID?

Thanks so much!

1 Answer 1


Check out this Apex Interface: InstallHandler Interface

Should allow you to query for the RecordType Id and insert it into the custom setting when the user installs the managed package.

  • Specifically, in the InstallHandler, you can create the custom setting records on the fly as a normal DML operation. You can get the record type ID values from DescribeResult's getRecordTypeInfo*() functions (you'll probably want to get it by name, getRecordTypeInfosByName()).
    – sfdcfox
    Jan 14, 2015 at 7:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .