Fixing UCI Custom View Filter Caching Issue

Problem
Customer filter is applied to system view because of caching

Details
Recently we got one issue reported where system view was not displaying all the records based on the default filter, but when we tried to reproduce the issue when we tried to check the view directly but when we tried to follow steps based on the QA resource we found some customer filter is applied automatically to the view when user want accessing that view after opening specific entity form.

While troubleshooting this issue I found we have a custom view filtering applied in the entity, where we had following code:

            var ViewDisplayName = "Displayname of the view";
            var viewId = formContext.getControl(lookupfieldname).getDefaultView();
            //rest of the FetchXML code
          
           formContext.getControl(cra).addCustomView(viewId, entity, ViewDisplayName, fetchXML, layout, true);

In the above code we were using Default view id to set the custom view id and that was causing this issue, so we changed code using new hardcoded GUID like below

        
            var viewId = "new guid;
            //rest of the FetchXML code

After above changes our issue got resolved and our view had only default filter applied !!

Summary
While setting custom view filter, we should not use CRM view id as this may add custom filter to the system view.

Hope it will help someone!
Keep learning, Keep sharing !!

Leave a Reply

Your email address will not be published. Required fields are marked *