web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

Unable to delete duplicate SecurityUserRoleOrganizations

(5) ShareShare
ReportReport
Posted on by 11
Hello,
 
Somehow we have some SecurityUserRoleOrganizations that are duplicated. I can see that this request returns multiple that differ only in etag.
 

 

GET <base_url>/data/SecurityUserRoleOrganizations?$filter=UserId eq 'SOME_USER'
 
    {
      "@odata.etag": "<etag>",
      "UserId": "SOME_USER",
      "SecurityRoleIdentifier": "<SecurityRoleIdentifier>",
      "OrganizationType": "LegalEntity",
      "OrganizationId": "LE1",
      "OperatingUnitType": "None",
      "HierarchyType": ""
    },
    {
      "@odata.etag": "<a different etag>",
      "UserId": "SOME_USER",
      "SecurityRoleIdentifier": "<SecurityRoleIdentifier>",
      "OrganizationType": "LegalEntity",
      "OrganizationId": "LE1",
      "OperatingUnitType": "None",
      "HierarchyType": ""
    }
 

The problem is that if we try to delete this object, Dynamics returns an error because we are trying to delete multiple entities at the same time.

 
DELETE <base_url>/data/SecurityUserRoleOrganizations(UserId='SOME_USER',SecurityRoleIdentifier='<SecurityRoleIdentifier>',OrganizationType=Microsoft.Dynamics.DataEntities.OMInternalOrganizationType'LegalEntity',OrganizationId='LE1')
{
  "error": {
    "code": "",
    "message": "An error has occurred.",
    "innererror": {
      "message": "More than one resource was found when selecting for update.",
      "type": "Microsoft.Dynamics.Platform.Integration.Services.OData.ODataArgumentException",
      ....
}
 
Is there a way to delete these duplicate with API call ?
  • Suggested answer
    Jo_Blessan Profile Picture
    114 on at

    Hi,

    The delete fails because the entity key (UserId, SecurityRoleIdentifier, OrganizationType, OrganizationId) is the same for both rows, so OData finds two matches and won't pick one. The only difference is the etag, which can't be used as a key. So this call won't work for these rows.

    1. In the UI, go to System administration > Users, open the user, and remove then re-add the role / organization assignment. That may clear both rows.

    2. Remove and re-add the role for the user via SecurityUserRoles, then check whether the duplicates are gone.

    3. Delete the extra row by RecId using a small X++ job (the underlying table should be SecurityUserRoleOrganization). Test in a sandbox first.

    4. If this is production, a Microsoft support case is worth raising.

    It would also help to find out how the duplicates were created (e.g. an import or integration assigning the role twice), otherwise they may come back.

    Hope this helps!
    Thanks.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the August Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 507 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 419 Super User 2026 Season 2

#3
CU-1234529-002 Profile Picture

CU-1234529-002 155

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans