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
stevenjinstevenjin 

Field IDs and Server Instance Split

A Salesforce Organization that I'm involved in is going to be part of a server split.  Somewhere in this I have a controller that uses a hard coded field ID in order to prepopulate fields when visiting a link.  Am I correct in thinking this will be affected in the server split?

Is there a way to dynamically get the ID of the field so I don't have to hard code this in?
Best Answer chosen by stevenjin
Cory CowgillCory Cowgill
Yes this will most likely impact your org. The SFDC Best Practice is not to hard code the ID's a field in your Apex / VF / Javascript code.

Here are two common options to solve your problem.

1. Move this from a hard coded ID to a Custom Setting. If you move this to a Custom Setting, when you move your Org you can easily change the ID of the field without doing a code deploy.

2. Instead of using Hard Field ID's look at using FieldSets to accomplish your goals. This is why Field Sets where built in the first place. http://www.salesforce.com/us/developer/docs/pages/Content/pages_dynamic_vf_field_sets.htm

 

All Answers

Cory CowgillCory Cowgill
Yes this will most likely impact your org. The SFDC Best Practice is not to hard code the ID's a field in your Apex / VF / Javascript code.

Here are two common options to solve your problem.

1. Move this from a hard coded ID to a Custom Setting. If you move this to a Custom Setting, when you move your Org you can easily change the ID of the field without doing a code deploy.

2. Instead of using Hard Field ID's look at using FieldSets to accomplish your goals. This is why Field Sets where built in the first place. http://www.salesforce.com/us/developer/docs/pages/Content/pages_dynamic_vf_field_sets.htm

 
This was selected as the best answer
stevenjinstevenjin

Hey Cory,

Thanks for the reply.  I am using the field ID to prepopulate a form thorugh URL using the CF0+ID format.  I think what you mean by field sets is to create a custom VF edit page in which case I can just pass the parameters in the URL?  Currently I am linking to the standard edit page so I would have to create another VF page for this.  Not sure of what I'll do at the moment. 

Thanks again for the answer.