Friday, July 11, 2008

Pre-Filter Lookup

I ran across some code today that will pre-filter a lookup field based on a selection in another lookup field.

Put this in the onChange of the first lookup:

document.filterLookup(crmForm.all.customerid, crmForm.all.contactid);

Put this in the onLoad of the form:

// Filtered lookup
document.filterLookup = function (source, target) {
if (IsNull(source) IsNull(target)) {
return;
}
var name = IsNull(source.DataValue) ? '' : source.DataValue[0].name;
target.additionalparams = 'search=' + name;
}


For a more in-depth method of achieving this, visit this blog: http://jianwang.blogspot.com/2008/05/mysterious-crm-lookup-ii.html

No comments: