Showing posts with label Advance Find. Show all posts
Showing posts with label Advance Find. Show all posts

Monday, December 8, 2014

Bulk Hide Entities from Advance Find in MS Dynamics CRM


Hello World,

If you are in trouble with unnecessary Entities in your Advance Find (that you created while ago and no longer needed) but you don't want to remove them. And you want to hide them from your customers. And you are too lazy and you want one query that works for all. :)
I was that lazy.

EntityMetadata.IsValidForAdvancedFind Property 

     - Gets or sets whether the entity will be shown in Advanced Find

if IsValidForAdvancedFind = 1 
then referring entity will be shown in Advance Find.


Therefore to hide a entity from Advance Find we can write - 

         update MetadataSchema.Entity
         set IsValidForAdvancedFind = 0
         where  Name = 'EntityName' 

Above will hide the contact  entity for all users  on the advanced.


Then to hide the Entity been displayed under related Entities we can write,

update MetadataSchema.Relationship 
set IsValidForAdvancedFind = 0
where ReferencingEntityId = (select MetadataSchema.Entity.EntityId 
    from MetadataSchema.Entity 
    where Name = 'EntityName') and IsValidForAdvancedFind  = 1)


If you have multiple Entities to update you can easily change the '=' to 'IN' and write all the Entities as a array.

update MetadataSchema.Entity 
set IsValidForAdvancedFind = 0 
where Name IN ('EntityName1', 'EntityName2', ......)


Hope this would be useful
Mathee