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