+ Start a Discussion
fjw07039fjw07039 

Modify lookup field dialog to search on alternate fields

I have an application with a transaction record that has a lookup field to an employee object.  The name field in the employee object is the employee id.  We'd like to create our own lookup search page that allows the user to enter the employee name instead of the id.  This is similar to the filter functionality only it would be the initial search.  We know how to customize the lookup page but we would like to add a button, similar to the lookup icon, to the edit page to invoke our custom code.  Unlike display pages, it does not appear that you can embed a piece of Visualforce code on an edit page.  Do we really have to recreate the entire edit page in Visualforce or are we missing something?
Arvind1Arvind1

Hi,

 

I think you can use javascript to invoke your lookup page. Instead of going for a custom button you can use the

lookup field itself.

 

 try { window.sfdcPage.appendToOnloadQueue(initForm);} catch(e) {}
function initForm() {
overrideLookup("javascript: openLookup('/apex/AccountLookup?type=BillTo&lkfm={!$Component.form_order}&lknm={!$Component.form_order:order_header:order_info:section:account}&lktp=' + getElementByIdCS('{!$Component.form_order:order_header:order_info:section:account}_lktp').value,670,'1','&type=BillTo&oid={!id}&lksrch=' + escapeUTF(getElementByIdCS('{!$Component.form_order:order_header:order_info:section:account}').value))","{!$Component.form_order:order_header:order_info:section:account}_lkwgt");

The ids given in this function is the id of the lookup field.

 

function overrideLookup(href,id) {
var elLookup = getElementByIdCS(id);
if (elLookup != null) {
elLookup.href = href;
}
}
APetersAPeters

Hi,

 

I'm also trying to build my own OpenLookup-Logic (apex-code and page) so it seems the orignial posting is exactly the question i am looking for. My goal is to replace the standard lookup functionality on custom apex-pages and standard page-layouts.

 

So I'm really happy to see, that someone else is looking for the same solution.

 

My question is: where do i place your code? There seems to be no place to put any javascript-code in standard page layouts.

 

Any tips? Or is this only possible in custom apex-pages?

 

Thx in advance

 

regards

 

André Peters

Mike CaoMike Cao

Hi,

    You can put your standard page into a iframe ,and then ,you can do whatever you want with the id of component.