Skip to main content

Notifications

Announcements

No record found.

Customer experience | Sales, Customer Insights,...
Suggested answer

BulkDeleteRequest error (OwnershipNotFoundInExceptionOwnerSettings)

Posted on by

I am attempting to do a BulkDeleteRequest of Opportunity Products but am hitting the below error, any ideas what the error is referring to?

I'm an admin in the Dynamics instance and have delete permissions on the object.


Plugin code for BulkDeleteRequest:


public void DeleteProducts(IOrganizationService dynamicsService, ITracingService tracingService, Guid oppId, EntityCollection opp_prod)
{

    tracingService.Trace("Configure One: PrimaryQuote - DeleteProducts");
    List productsToDel = new List();
    foreach (Entity product in opp_prod.Entities) {
        productsToDel.Add(product["opportunityproductid"].ToString());
    }

    tracingService.Trace("define delete query");


    ConditionExpression condition = new ConditionExpression()
    {
        AttributeName = "opportunityproductid",
        Operator = ConditionOperator.In
    };
    condition.Values.AddRange(productsToDel);

    FilterExpression filter = new FilterExpression();

    filter.Conditions.Add(condition);

    var query = new QueryExpression{
        NoLock = true,
        Criteria = filter,
        Distinct = false,
        EntityName = "opportunityproduct"
    };

    tracingService.Trace("define delete request");

    BulkDeleteRequest req = new BulkDeleteRequest()
    {
        RequestName = "Delete Opportunity Products from previous Primary",
        JobName = "Delete Opportunity Products from previous Primary",
        StartDateTime = DateTime.Now,
        SendEmailNotification = false,
        RecurrencePattern = String.Empty,
        QuerySet = new QueryExpression[] {
        query
        }
    };


    // Submit the bulk delete job.
    // NOTE: Because this is an asynchronous operation, the response will be immediate.

    tracingService.Trace("send req");

    dynamicsService.Execute(req);

    tracingService.Trace("req sent");



}


Error:

Exception type: System.ServiceModel.FaultException`1[Microsoft.Xrm.Sdk.OrganizationServiceFault]
Message: Delete Opportunity Products from previous Primary#2011/Organization.svcDetail:

6b9f824b-453a-4b46-9a11-3c18f1ab7a91
-2147220715


ApiExceptionSourceKey
Api/PrePipeline


ApiSourceActivityKey



ApiExceptionOwnerKey
OwnershipNotFoundInExceptionOwnerSettings


ApiOriginalExceptionKey
Microsoft.Crm.CrmNotSupportedException: Delete Opportunity Products from previous Primary#2011/Organization.svc
at Microsoft.Crm.Caching.SdkMessageRequestCacheLoader.GetSdkMessages(ExecutionContext context, Boolean isOperationIntentAvailable, SdkMessageRequestKey key)
at Microsoft.Crm.Caching.SdkMessageRequestCacheLoader.LoadCacheData(SdkMessageRequestKey key, ExecutionContext context)
at Microsoft.Crm.Caching.ObjectModelCacheLoader`2.LoadCacheDataInternal(TKey key, Object existingDataContainer, IOrganizationContext context)
at Microsoft.Crm.Caching.CrmMultiOrgCacheBase`2.<>c__DisplayClass38_0.b__1()
at Microsoft.Crm.SqlTelemetryHelper.LogSqlTimes(Action action, String operationName)
at Microsoft.PowerApps.CoreFramework.ActivityLoggerExtensions.Execute(ILogger logger, EventId eventId, ActivityType activityType, Action action, IEnumerable`1 additionalCustomProperties)
at Microsoft.Xrm.Telemetry.XrmTelemetryExtensions.Execute(ILogger logger, XrmTelemetryActivityType activityType, Action action)
at Microsoft.Crm.Caching.CrmMultiOrgCacheBase`2.CreateEntry(TKey key, IOrganizationContext context)
at Microsoft.Crm.Caching.CrmMultiOrgCacheBase`2.<>c__DisplayClass19_0.b__0()
at Microsoft.PowerApps.CoreFramework.ActivityLoggerExtensions.Execute(ILogger logger, EventId eventId, ActivityType activityType, Action action, IEnumerable`1 additionalCustomProperties)
at Microsoft.Xrm.Telemetry.XrmTelemetryExtensions.Execute(ILogger logger, XrmTelemetryActivityType activityType, Action action)
at Microsoft.Crm.Caching.CrmMultiOrgCacheBase`2.LookupEntry(TKey key, IOrganizationContext context)
at Microsoft.Crm.Caching.CrmEntitySharedMultiOrgCache`2.LookupEntry(TKey key, IOrganizationContext context)
at Microsoft.Crm.Extensibility.OrganizationSdkServiceInternal.GetRequestDescription(String requestName, IOrganizationContext context)
at Microsoft.Crm.Extensibility.OrganizationSdkServiceInternal.ExtractSdkParameteres(OrganizationRequest request, OrganizationContext context, SdkRequestDescription& requestDescription, String& primaryEntityLogicalName, Int32& primaryEntityTypeCode, Int32& secondaryEntityTypeCode)
at Microsoft.Crm.Extensibility.OrganizationSdkServiceInternal.<>c__DisplayClass22_0.b__0()


ApiStepKey
00000000-0000-0000-0000-000000000000


ApiDepthKey
3


ApiActivityIdKey
6b9f824b-453a-4b46-9a11-3c18f1ab7a91


ApiPluginSolutionNameKey
System


ApiStepSolutionNameKey
System


ApiExceptionCategory
ClientError


ApiExceptionMessageName
NotSupported


ApiExceptionHttpStatusCode
405


http://go.microsoft.com/fwlink/?LinkID=398563&error=Microsoft.Crm.CrmException:80040315&client=platform
Delete Opportunity Products from previous Primary#2011/Organization.svc
2022-06-20T10:59:04
false
SdkClientError

SdkClientError

  • Suggested answer
    - Matt Bayes - Profile Picture
    - Matt Bayes - 890 on at
    RE: BulkDeleteRequest error (OwnershipNotFoundInExceptionOwnerSettings)

    Hey RyanCRM,

    Looking at the documentation for the BulkDeleteRequest message, I believe you may be missing some required properties for the request.

    In this case, I don't see either the ToRecipients or CCRecipients in your request.


    Based on the error message, my thought is that the OwnershipNotFoundInExceptionOwnerSettings error message pertains to there being no recipients set on the Bulk Delete Request, and thus the "Ownership" of the request does not have any context to user(s).

    Try adding those two properties to the request and see if it solves your issue. The documentation for those parameters is found here:
    https://docs.microsoft.com/en-us/dotnet/api/microsoft.crm.sdk.messages.bulkdeleterequest?view=dataverse-sdk-latest

    Hope this solves the problem! Thanks!


    Matt Bayes

  • Jimmywick Profile Picture
    Jimmywick 70 on at
    RE: BulkDeleteRequest error (OwnershipNotFoundInExceptionOwnerSettings)

    The failures of the BulkDeleteOperation are stored in the BulkDeleteFailure records and can be retrieved by using the RetrieveRequest message or the RetrieveMultipleRequest message. A bulk delete job deletes the specified records according to the cascading rules. These rules are based on the relationship type between the tables.

    Hope this help,

    J Wick

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans