What is Issue?
Ms CRM provides the way to query the records in system with or without some filter criteria. There might be some conditions where we need to restrict user from querying for the entity, but still we want to have read privilege to the entity so that we can provide the visibility to the records in some desire areas. But the MS Dynamics CRM don’t have any separate option to hide/show the entities in Advanced find.
The Reason-
Ms CRM handles the entities to be visible in advanced find using Security Role. If Any entity don’t have read privilege for the security role, the entity will be hidden in advanced find for that security role. This is internally handled by “IsValidForAdvancedFind” read-only flag.
Solution-
There are multiple solution to make entity hidden from advanced find like –
A. Security Role
B. Database Query
C. RetrieveMultiple Message Override
D. Custom Code
A. Security Role –
Remove the read privilege for security Role you want to hide entity. But this security role will don’t have any read permission for the entity Records.
B. Database Query –
If you have on-premise setup, you will have database control.
So you can make “IsValidForAdvancedFind” flag False to make entity hidden in advanced find only.
C. RetrieveMultiple Message Override –
This is the simple and reliable way to make records available to the user. Create the plugin for the entity with the modified query, so that user will have visibility to the records by default which you set. This will affect overall application i.e. in subgrids, home view and where ever the retrievemultiple is called.
But this is not suitable for our requirement i.e. Hiding Entity from advanced find without any access changes to the records.
D. Custom Code – Javascript
The way I found is very easy. Within few steps you can achieve it.
Let’s say I want to hide Account and Contact entity from Advanced find.
1.Create a new solution with component “Application Ribbon” in it.
2. Create a New Javacript webresource with below Code-
in my case – Name and Display Name – “mct_/Scripts/AdvancedFind.js”
//entities to be hidden var entities = [ 'account',//Account 'contact',//Contact ]; //slctPrimaryEntity is id of dropdown for entities displayed in Advanced Find. function hideEntities() { var select = $("#slctPrimaryEntity"); if (select.length > 0) { for(var i = 0; i < entities.length; i++) $("#slctPrimaryEntity option[value='" + entities[i] + "']").remove(); } //find and hide button which we are going to create in next step. var button = window.top.document.getElementById("new.ApplicationRibbon.Button.RemoveEntities-Large"); if (button !== undefined && button != null) button.style.display = "none"; return false; }
3. Open your new solution in Ribbon Workbench.
4. You will find the set of commands which are used in Advanced find. Add new button with minimum information, next to the “DOWNLOAD FETCHXML” button or at the end of this group.
ID : new.ApplicationRibbon.Button.RemoveEntities
5.Create a Command
ID : new.ApplicationRibbon.Command.RemoveEntities add this command in newly added button : Command :- new.ApplicationRibbon.Command.RemoveEntities CommandCore :- new.ApplicationRibbon.Command.RemoveEntities
6. Add Enable Rule to the Command –
Enable rule details-
ID : new.ApplicationRibbon.EnableRule.RemoveEntities
Add Custom Rule :-
Default - True Function Name - hideEntities (our custom Javacsript function name) Library - $webresource:mct_/Scripts/AdvancedFind.js (our custom Javascript)
7. Publish the Solution.
And Done.
You can check advanced find – There is no Account and Contact entities available.
Hope this will help…
Enjoy Ms CRM!!!
Follow on Facebook- FB: MSCRM16Tech
JavaScript option is unsupported way of doing it. You are accessing window object which is not supported. You dont know with which update it will stop working.
LikeLike
Yes Ashish, but till next update hope Microsoft will provide something different option to choose entities which you want to show in advanced find.
LikeLike
Hi Prakash,
I used this method to hide a custom entity. Entity gets hidden but when I click on Advanced find from the entity, the views do not hide. Also if I click on Create View button from the record, it opens advanced find and entity is hidden, but the views are not hidden. Can you please help with this
LikeLike
Hi Kavitha,
It’s windows object work using javascript. You can do the required action by two ways-
1. You can change look-for entity dropdown with other option if advanced find is opened from hidden entity.
2.You can play with view drop-down as well.
And It’s Prashant not prakash.😊
LikeLike