You need to sign in to do that
Don't have an account?
Prepopulating custom Lookup
Hi,
We have custom Customers Object, in which we have a record type that stores the customer location. For this we are storing the corresponding customer ID in a custom lookup field for customer location record.
we are showing the customer location records in the related list of the customer object. we are creating the customer location record using a custom button in the related list , for this button click we are passing recordtype=recordtypeid in the url , so that the page navigates to the customerlocation record type by default.
The problem , we need to pre-populate the parent customer id for the corresponding customer location record.
In the salesforce documentation it was given that if we pass the html id of the lookup fields in the query string , the values will be populated automatically.
e?CF00NA000000248R5=C-1689&CF00NA000000248R5_lkid=a0MA0000000h8UN&RecordType=012A0000000DDSvIAO&retURL=/a0MA0000000h8UN
This is working fine with in an Specific Org, but if we move the code into another org, the html id of the lookup wont be the same , and the lookup is not populating.
Any ideas on how to proceed on this ?
Thanks,
yvk431
We store the html id in the custom setting.
All Answers
We usually put the information into a custom setting. You can then retrieve this in the custom button code and dynamically generate the correct URL.
can you be more specific , what do you mean by storing the information in custom settings.
Are you saying to store the html code ?
We store the html id in the custom setting.
Hey my problem is not with storing the HTML code , if I knew the code i can sent it directly in the query string right!!
The HTML code of a lookup field is different from one Org to another .
the following are the lookup field html code from other Org
CF00NA0000003Bjsc=test&CF00NA0000003Bjsc_lkid=a0aA00000009qPr
Please correct me , if I am missing something.
I've been waiting on this for so long , please help me out.
I'm confused now. I though the issue was that your button would not work across orgs as the HTML ids for the input fields change. Storing the ids in custom settings means that you don't have to change your code each time to move to a different org, but simply update the custom setting.
Are you expecting to be able to programatically determine the ids? If so, I think you are out of luck.
i thought , we can get the html code some way using Describe Object .
Anyways , i will go for custom settings, as you said there is no other way.
Thank You bob
Hi Bob,
I tried using custom setting and its working fine, but i got stuck in populating when making the lookup field read only.
If I give readonly permission to the lookup, it was not populated by the values I am passing through query string.
Let me know , how to get pass this
Thanks,
yvk431
If you make the lookup field readonly, you won't be able to write to it. If you try to use a readonly field as the value for an inputfield, it will behave like an outputfield when rendered on the page.
If you need to write the data into the field at render time but not let the user change them, you might want to look at passing information on the URL that is processed by a custom/extension controller at construction time, as controllers of this sort run as a system user.
Hi Bob,
How to store te HTML Ids in Custom Settings. Can you please give me an example ?
I just want to store lookup field.
Thanks in advance
Hi Bob,
I am trying to do the same thing and everything works fine except the read only part. How do you go about populating the field based on querystring and also make it read only? I want to use standard page layout. Thanks.
Sanch.