Search code examples
securityaxaptadynamics-365-operations

Assignment of legal entity to roles for users via dmf


I m in need to find the data entity which will help to assign legal entity to a role in bulk through dmf. The below link provides information for manual and organization hierarchy for the same process. https://alexdmeyer.com/2020/01/07/options-for-configuring-user-legal-entity-restrictions-in-d365fo/

Kindly help.


Solution

  • TLDR

    You are looking for entity "System security user role organization" (SystemSecurityUserRoleOrganizationEntity).

    Note that there is a second entity with the technical name SystemSecurityUserRoleEntity (without Organization) that unfortunately uses the same label. Make sure you use the correct one. Also note that this entity exists since version 10.0.11.

    DIY

    To find this information yourself in case you have a similar "What is the entity for x?" question in the future, here is the details of what I did to find the entity:

    First, I followed the instructions from the link you provided to the form of the "Assign organizations" function. There, I checked what table is used as the data source for the grid in the lower part of the form where records are created when the "Grant" function is used. This told me that table OMUserRoleOrganization stores the data where legal entities are assigned to the roles of a user.

    Next, I opened up Visual Studio, navigated to the table in the application explorer and used the context (right click) menu to find the references of the table. A bit down the list, you will notice that several entries start with dynamics://*. These are metadata references (e.g. a data source in a form) instead of code references. In this case, you are looking for a metadata reference that starts with dynamics://DataEntityView/*. This identifies data entities where the table is used, usually as a data source in the query of the entity. In this case, only one entity is found, SystemSecurityUserRoleOrganizationEntity. If you look at the fields of this entity, they match your requirement of specifying a user, a role and a legal entity.

    To test the entity, I assigned an user's role to an organization (Contoso data doesn't seem to have this) and created an export project with the entity. This gives me the following result:

    enter image description here