function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
CharlieLangCharlieLang 

Field ID's & sandboxes

Hi,

 

We have a config sandbox linked to a full sandbox, linked to production.

 

We are in the process of implementing some new code, can someone help me - do the field ID's change between the environments?

 

for example, we have a button that does a custom clone via a VF page and updates a lookup field. this field, do the ID's change between the different orgs or / and will salesforce auto correct this?

 

Thanks for any help in advance

Best Answer chosen by Admin (Salesforce Developers) 
craigmhcraigmh

I only said "SControl" because I looked at my list of prefixes and saw that "01N' meant SControl, completely misreading the actual ID. Regardless, yeah, you can just query for the value and use that if you have a decent way to reference it.

 

List<RecordType> RTs = [Select Id From RecordType Where Name = 'This is my record type' Limit 1];
Id myRecordType;
if(RTs.size() > 0) { myRecordType = RTs[0].Id; }

 

All Answers

craigmhcraigmh

Yes. Configuration-only sandboxes will most likely have different IDs for records. Only full-copy sandboxes will preserve the IDs.

CharlieLangCharlieLang

hmmm... 

 

a normal field is the following

in a config sandbox a field ID is 00N20000001CdTh

in the full sandbox the field ID is 00N20000001CdTh

In the production instance is 00N20000001CdTh

 

Lookup fields look like the following

config 00ND0000003jGJ2

full 00NL0000000JtOB

production 00ND0000003jGJ2

 

so i need some advice. If i am building some VF that uses the field ID and the _lkid to fill the lookup, should i just deploy from the config sandbox to production? or is there a way to match everything up between config / full / production?

craigmhcraigmh

Well the IDs depend on what you're doing with the data. If you have a record in Production and refresh the Full sandbox, the ID will be the same. If you create a record in both after the refresh, they will have different IDs.

 

If you're coding a VisualForce page with an ID in it, you're doing it wrong. If it's an SControl, you should be able to query for the ID of the SControl in your controller class, then expose that ID as a property to your VisualForce page.

CharlieLangCharlieLang

apologies, there is an apex class doing the work.

 

having a look at the clients full sandbox the last refresh was over a year ago so i will suggest they refresh it  then i will re-deploy from dev to full and then check.

 

Thanks for the help

craigmhcraigmh

I only said "SControl" because I looked at my list of prefixes and saw that "01N' meant SControl, completely misreading the actual ID. Regardless, yeah, you can just query for the value and use that if you have a decent way to reference it.

 

List<RecordType> RTs = [Select Id From RecordType Where Name = 'This is my record type' Limit 1];
Id myRecordType;
if(RTs.size() > 0) { myRecordType = RTs[0].Id; }

 

This was selected as the best answer
CharlieLangCharlieLang

Its not the record ID thats become disjointed, its the actual ID of the lookup field. config and prod are the same, full is different.

craigmhcraigmh

Yeah, but the methodology should still get you what you need, right?

CharlieLangCharlieLang

yeah i guess, i will give it a go