cancel
Showing results for 
Search instead for 
Did you mean: 

Xrm.Utiltiy.LookupObjects filters not working

CE Xrm.utility.lookupobjects method filters property is not working in UCI and Classic UI for version 9.0.I couldn't find a documetnation or samples on filters.

Status: New
Comments
Anonymous
Not applicable

I have been trying all kinds of different ways to provide the filters and cannot seem to get them working. My test scenario is also using the Unified Interface.

 

Would love to hear if anyone else managed to solve it.

Anonymous
Not applicable

There's certainly a "feature gap" in the lookup dialog implementation. The CustomViews do not work in UCI that means the use of customized fetch Xml and layout Xml are out of the window. In addition to that, the dependency of using system view requires us to use guids for those views inside the JavaScript, which looks far away from a user friendly design (code-wise even). The filterXml also gets applied across all views so the whole point of choosing multiple views is lost. Lastly, the design of lookup dialog is so different and hard to use that a user moving from Legacy to UCI will have an extremely hard time working with that in general. 

 

step 1, shows history - no option yet to change view. History is shownstep 1, shows history - no option yet to change view. History is shownafter you click the search bar and press enter, then data is loaded with button to change viewafter you click the search bar and press enter, then data is loaded with button to change view

 

In UCI, we have the lookup dialog opening without showing the "change view" button, first you have to click on the search bar and press enter to get the records displayed, then it shows the "change view" button. After that you're able to click on it which shows another list of views. So the point is that the whole UI interaction is looking odd too. 
We are an ISV with several big customers depending on the lookup dialog and this is far from expectation and breaking existing functionality. So I'd like to request and further extension of the December 1 deadline for UCI migration until this gap is fixed for both onprem and online. Also please provide a supported way to differentiate between UCI and Legacy considering the `Xrm.Internal.IsUci()` method.

Consider how easy it is in Legacy UI to switch views and the luxury of proving custom fetch xml instead of providing guids for system views and overlapping fetch xml.
lookupObjectLegacyBlur.png

J-Dodds
New Member

I forgot to circle back here, but I did eventually get the filters working in UCI. I can't recall how I figured it out, but here is an excerpt from my working code for it:

 

const propertyLookupView = "{INSERT-GUID-OF-VIEW-HERE}";
var fetch = "<filter type='and'><condition attribute='xrm_file' operator='null' />" + "</filter > ";

var filters = [{
entityLogicalName: "xrm_property",
filterXml: fetch
}];
var lookupParameters = {};

lookupParameters.entityTypes = ["xrm_property"];
lookupParameters.defaultEntityType = "xrm_property";
lookupParameters.defaultViewId = propertyLookupView; //Property Lookup View
lookupParameters.viewIds = [propertyLookupView];
lookupParameters.allowMultiSelect = true;
lookupParameters.filters = filters;
lookupParameters.disableMru = true;

Xrm.Utility.lookupObjects(lookupParameters);

 

In my example I am looking up "Property" records to add to a File, but only where they are not linked to another File. My Property Lookup view does not have the filter in it. The trick seems to be the structure of filters being an array of objects defining the entity logical name to apply the filter to and the filterXml as properties.

 

I hope that helps someone.

Jeff

rocky1857
New Member

Thanks for the input Jeff. The trouble is the filters get applied to all views, they're not bundled with one individually. If there's one view only then it works fine, but not in case of multiple views as far as we've discovered.

furkankaracan
New Member

Is this a bug or is this how supposed to work? If it isn't bug and we cant provide a default view for lookup dialog it is extremly unpractical.