Hi Community,
We have a requirement where we need to find if positional hierarchy is enabled in Dynamics CRM using C# code.
Also we need to check for the list of excluded tables in the hierarchy using C#.
It would be really helpful to us if we get any solution regarding our above queries.
Thanks and regards.
Thanks a ton! R@y .
Your answer really helped us alot.
Regarding the enable hierarchy option of Dynamics CRM, i did some research of my own and got the answer.
Thanks and regards,
Bharat.
Hi Bharat,
There is an attribute in organization entity/table usepositionhierarchy, you can check this attribute.
There is a(n) entity/table hierarchysecurityconfiguration. All the tables excluded from the hierarchy will have a record in this table.
Here is the example code to retrieve all the records:
// query if hierarchy is enabled var queryOrg = new QueryExpression("organization"); queryOrg.NoLock = true; queryOrg.TopCount = 1; queryOrg.ColumnSet = new ColumnSet("usepositionhierarchy"); var organizationEntityCollection = OrgService.RetrieveMultiple(queryOrg); var usePositionHierarchy = organizationEntityCollection.Entities.First().GetAttributeValue("usepositionhierarchy"); // query execlued entity var query = new QueryExpression("hierarchysecurityconfiguration"); query.NoLock = true; query.ColumnSet = new ColumnSet(true); var excludedEntityCollection = OrgService.RetrieveMultiple(query);
configuration screenshot:
Query result with SQL 4 CDS tool:
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156