Hello everyone!
I have create a small javascript to pre search lookup fields. Although it does work with hardcoded attributes , it won't work by passing arguments to the function.
This is my "hardcoded" function :
function preFilterLookup() { Xrm.Page.getControl("new_attribute").addPreSearch(addLookupFilter); } function addLookupFilter() { var fetchXml = "<filter type='and'><condition attribute='new_attributeRelatedField' operator='eq' value='false' /></filter>"; Xrm.Page.getControl("new_attribute").addCustomFilter(fetchXml); }
I have tried to pass the argument by using this function but i get error:
function preFilterLookup(fieldname) { Xrm.Page.getControl(fieldname).addPreSearch(addLookupFilter(fieldname)); } function addLookupFilter(fieldname) { var fetchXml = "<filter type='and'><condition attribute='new_attributeRelatedField' operator='eq' value='false' /></filter>"; Xrm.Page.getControl(fieldname).addCustomFilter(fetchXml); }
I think it has something to do with scopes of functions. I also tried to create a var in main function , and assign to it the fieldname parameter and then pass that variable into addLookupFilter but still didn't work.
Any help?
*This post is locked for comments