Filtered Lookup multiple Fields

310
February 20, 2017, at 7:21 PM

I want to filter the lookup on multiple field on one form. The problem is, that only the last eventhandler I added applied to all field. For this I wanted to use the context to get the field, which is currently used. But the filters are applied in the "onload" event of the form, where I don't have the selected context / field in it. For this I use this code :

function preFilterLookupFunction(executionContext) 
{
var fieldname = new Array("field1","field2");
fLen = fieldname.length;
for (i = 0; i < fLen; i++) 
{
    var tempName = fieldname[i];
    Xrm.Page.getControl(tempName).addPreSearch(function () 
    {
        addLookupFilterFunction(executionContext);
    });

}
}
function addLookupFilterFunction(executionContext) 
{
var attribute = executionContext.getEventSource();
var tempFieldName = attribute.getName();
alert(tempFieldName)
var condition = Xrm.Page.getAttribute("fieldContition").getValue();
if (condition != null) 
{
    var fetchXml = "<filter type='and'><condition attribute='fieldContition' operator='eq' value='" + condition + "' /></filter>";            
    Xrm.Page.getControl(tempFieldName).addCustomFilter(fetchXml);   
}   
}

My question - is it possible to get the context in the addLookupFilterFunction while executing, so I can set the filter to the right field ? Or is there a better way to filter multiple field on one form ?

READ ALSO
How focus is to be made to delete button in one to many field in odoo10 while traversing using tab key

How focus is to be made to delete button in one to many field in odoo10 while traversing using tab key

Focus will also go through the 'delete' button while traversing through one to many field using tab key in odoo10Now ,the focus doesn't enter the delete button

265
Build Photoswipe Flickr gallery

Build Photoswipe Flickr gallery

I want my PhotoSwipe gallery to pull images from Flickr, but so far have only managed to do this by adapting someone else's codeThe default photoswipe settings I originally worked with suit me much better, but I cannot figure out how to EITHER connect...

418
Change window.location.href in Firefox without closing websockets

Change window.location.href in Firefox without closing websockets

I am currently trying to trigger a file download using following code in Javascript: windowlocation

825
Are DOM circular references found by chrome,firefox and IE?

Are DOM circular references found by chrome,firefox and IE?

I was reading about DOM circular references and how they were a cause for memory leak in javascript especially in IE 6 and 7Do the modern browsers use mark-and-sweep technique to effectively remove these objects from memory?

304