You need to sign in to do that
Don't have an account?
satyan.sheshadri1
Field Filter lookup not working on VF page
Hello,
I have a 2 lookup field on custom object 'Inventory' a) User and 2) parent inventory.
I have added a filter that 'Parent inventory' lookup will display only those records related to user specified in 'User' lookup field.
This works fine on standard page but not on the VF page.
When I checked the URL of 'parent inventory' lookup window in VF page, it shows the below URL
https://c.ap1.visual.force.com/_ui/common/data/LookupPage?lkfm=j_id0%3AmainForm&lknm=j_id0%3AmainForm%3ApurchaseBlock%3Ainventory%3Aj_id51%3A0%3AParent&lkfield=00N90000009mP93&lkent=a00&lktp=a00&dplp=[null%2Cnull]&lksrch=
if i replace the 'dplp=[null%2Cnull]' with some use user ID like 'dplp=[null%2C00590000000hU1S]', then it works fine.
Please let me know how should I overcome it?
Thanks in advance.
I have a 2 lookup field on custom object 'Inventory' a) User and 2) parent inventory.
I have added a filter that 'Parent inventory' lookup will display only those records related to user specified in 'User' lookup field.
This works fine on standard page but not on the VF page.
When I checked the URL of 'parent inventory' lookup window in VF page, it shows the below URL
https://c.ap1.visual.force.com/_ui/common/data/LookupPage?lkfm=j_id0%3AmainForm&lknm=j_id0%3AmainForm%3ApurchaseBlock%3Ainventory%3Aj_id51%3A0%3AParent&lkfield=00N90000009mP93&lkent=a00&lktp=a00&dplp=[null%2Cnull]&lksrch=
if i replace the 'dplp=[null%2Cnull]' with some use user ID like 'dplp=[null%2C00590000000hU1S]', then it works fine.
Please let me know how should I overcome it?
Thanks in advance.
I hope the below links will help you.....
http://bobbuzzard.blogspot.in/2010/09/visualforce-lookup.html
Thanks,
Rockzz
I have created the custom filter lookup in onother way.
Regards,
Satyan
Hi Satyan,
How you created the custom filter lookup in onother way.Can you please paste code then I will learn another way also.
Thanks,
Rockzz
You must be aware that for lookup fields the ID's are stored in the field named ending with '_lkid'.
In my case for 'AllocatedTo' it is 'AlocatedTo_lkid'.
So on click of 'parent inventory' lookup, I fetch the user id from 'AlocatedTo_lkid' field and pass it to my page for filteration.
On the above page I have overriden the salesforce openlookup() method and displayed my visualforce page for both lookups, To display the list.
NOTE: If you override the openLookup() method you need to create visualforce lookup page for all the lookup fields.
my openlookup method:
function openLookup(baseURL, width, modified, searchParam) {
width = width+100;
var lookupType = baseURL.substr(baseURL.length - 3, 3);
var lookupTypeUser = baseURL.substr(baseURL.length - 18, 18);
var isCustomLookup = false;
if (lookupType == "005" || lookupTypeUser == "StandardUserLookup") { // lookup for standard user object
txtId = textFildId(baseURL)
baseURL = "/apex/CustomUserLookup?txt=" + txtId;
baseURL = baseURL + "&frm=" + escapeUTF("{!$Component.myForm}");
if (modified == '1') {
baseURL = baseURL + "&lksearch=" + searchParam;
}
if (txtId.indexOf('AlocatedTo') > -1) {
isCustomLookup = true;
}
} else if (isInventoryObj(baseURL)) { //isInventoryObt(): Checked if lookup is related to my object
txtId = textFildId(baseURL)
var fieldLocation = txtId
var allocatedfldID = decodeURIComponent(fieldLocation.replace('Parent','AlocatedTo_lkid'));
// fieldLocation also contains the row number. So you can get corresponding ID
var selectedUserId = document.getElementById(allocatedfldID).value;
baseURL = "/apex/FilteredInventoryLookup?txt=" + txtId+"&userId="+selectedUserId;
baseURL = baseURL + "&frm=" + escapeUTF("{!$Component.myForm}");
if (modified == '1') {
baseURL = baseURL + "&lksearch=" + searchParam;
}
if (txtId.indexOf('Parent') > -1) {
isCustomLookup = true;
}
}
console.log(isCustomLookup);
if (isCustomLookup == true) {
openPopup(baseURL, "Popup", 350, 550, "width=" + width + ",height=480,toolbar=no,status=no,directories=no,menubar=no,resizable=yes,scrollable=no", true);
}
}
__________________________________________________________________________
On the visualforce lookup page, you need to call salesforce javascriptmethod named : lookupPick2() on the outputlink, as follows:
<apex:pageBlockTable value="{!inventoryList }" var="inventory" id="tblResult">
<apex:column >
<apex:facet name="header">
<apex:outputPanel >Name</apex:outputPanel>
</apex:facet>
<apex:outputLink value="javascript:top.window.opener.lookupPick2('{!FormTag}','{!TextBox}_lkid','{!TextBox}','{!inventory.Id}','{!inventory.Name}', false)" rendered="{!NOT(ISNULL(inventory.Id))}">{!inventory.Name}</apex:outputLink>
</apex:column>
</apex:pageBlockTable>
______________________________________________________________________________
in the lookup controller, have following methods:
public performSearch() {
inventoryList = [select...........];
}
/* used by the visualforce page to send the link to the right dom element */
public string getFormTag() {
return System.currentPageReference().getParameters().get('frm');
}
/* used by the visualforce page to send the link to the right dom element for the text box */
public string getTextBox() {
return System.currentPageReference().getParameters().get('txt');
}
Thanks,
Satyan