[SalesForce] Refer to Record Type ID in Formula without Hard-coding

I'm building a Custom List Button in a Dev Environment, and I'd like it to work with no changes when deployed to Production even though all IDs will change.

The list button (which will be displayed in a related list) allows users to create a new related object, but specifies a specific Record Type, and pre-fills the new object with data from the current record.

It looks like this:

{!URLFOR( $Action.Contact.NewContact , null, [CF00NJ0000000QIX7=Contact.Id, RecordType="012J00000004NGB"])}

The problem is that this RecordType ID will change with deployment. I'll always know it's name, though. Is there any way to use that?

Update: Also, won't the custom field ID change also (CF00NJ0000000QIX7 above) — what do I do about that?

Best Answer

You can use custom setting for this. Keep the record type Id in custom setting and use that in your button code, it will look something like this "{!$Setup.CustomSettingAPI_c.RecordTypeId_c}"

Related Topic