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
Rocky.4QRocky.4Q 

Pre-Populating Fields

I'm doing a peer review this week I'm having issues with a suggestion for how to avoid hard-coding when prepopulating. The HTML field id's change when refreshing or from dev to ci > qa > prod. Should we avoid pre-populating all together, or is there a way to do this taht ensures we won't have to update hard-coded values ever>

spraetzspraetz

Are you talking about pre-populating fields on the standard salesforce UI or custom visualforce pages?  

Rocky.4QRocky.4Q

Their trying to populate a Custom Object edit page, and a Stadn Object edit page. One is using a custom button to pass via URL and one is using an Apex class to put the url params on and then redirect. Both, however require the html field ID in order to know which to populate.

jeremyyjeremyy

In the case of a VF page, if you're using a controller extension or custom controller, you can check for parameters (that you define) passed in the URL. This type of pre-populating is fully supported.

 

Standard objects are a different story, and this is one area of salesforce that everyone bends the rules (even salesforce professional services) by passing values in the URL using the field IDs. The field IDs are an implementation detail and are subject to change without notice, which is what makes this a gray area. However, salesforce customers have been doing this for as long as I can remember, and I've yet to experience an upgrade that caused previously created links to break.