+ Start a Discussion

Pre-populate fields on standard page from link in package

I have the need to pre-populate certain data fields on a standard custom object page. The data will come from a Visualforce page. I have seen several posts detailing how to do this using the field Id. However, I need to package this code and install in various other orgs which will all have different field Ids. Some of these posts claim that the packaging mechanism will modify the field Ids to fit the target org, but I can't seem to get that to work. 



<apex:commandButton action="{!URLFOR($Action.Test_Line__c.New, null)}&CF00NA0000004cg8S={!Test__c.Name}" value="New Test Line" />

This is trying to add a new Test Line object that references an existing Test object. The field Id for Test__c.name is 00NA0000004cg8S. The "CF" gets prepended to make the control Id on the page.


There doesn't seem to be a programmatic way to get field Ids. And I don't see how the packaging system can recognize that "CF00NA0000004cg8S" is a field Id in order to replace it. Is there another way to do this that will result in a successful field Id replacement?







It is true that salesforce does automatically reassign the ids  if the code is managed package, I have myself tried this with report, wherein I had custom links refering to a report id , and when I installed it in another org or for that matter several other orgs the conversion did happen automatically. But in case you are not comfortable with the idea of hardcoding  , which is understandable, you can perhaps use a custom object which will store these ids, something like a custom settings object an.d as you install your app for different orgs you will populate this object with appropriate ids, and your code will be so structured that it will generate the URL after querying the ids in the custom object.


Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.


This is currently in an unmanaged package, but will be managed eventually. Currently, I can just edit the page. It would seem the only option for a managed package would be to use a custom setting, like you said. However, the goal would be not to have any effort required after package installation. Instead you have to install the package. Go into setup. Find the Test_Line__c object. Click on the Test__c field. Go up to the URL and grab the Id. Enter that for the value of CustomSettingX. Repeat for x number of fields.


Obviously something automated would be much more desirable.