locked
CRM 2013 plugin salesorderdetail error on page -2146828218 or 800A0046 RRS feed

  • Question

  • I have an issue with on-premise CRM 2013 and a plugin. I have added custom attributes to the salesorderdetail entity. A text string attribute (purchaseorderid) and an option value attribute (stockstatus). I also have custom entities (purchaseorder and poproduct). The postcreate plugin on the poproduct entity updates the purchaseorderid field as a string in the  salesorderdetail entity (purchaseorderid) and the stockstatus option value (stockstatus). The information updates correctly with no exceptions thrown from the plugin. The issue is, after the plugin runs, when you open a salesorderdetail form, you get an error on page error andwhen you close the form you get the following error:Microsoft Dynamic CRM has encountered an error. The error detail is   <Message>Permission denied</Message>   <ExceptionNumber>-2146828218</ExceptionNumber>. After the initial error, you can open and close the salesorderdetail form without error. Also, the error happens on any salesorderdetail record, not necessarily the one that was updated. It doesn't even have to be the same sales order. Once a salesorderdetail record has benn opened and closed, you don't get the error again. Here is the code, excuse the trace statements:

            public Boolean UpdateSalesOrderDetailWithPODetail(IOrganizationService service, OrganizationServiceContext serviceContext, ITracingService tracingService, Guid gPODetailID, Guid gSalesOrderDetailID, Decimal cCost, int istatusReason)
            {
                tracingService.Trace("In NSTCCRMPOProductDal.UpdateSalesOrderDetailWithPODetail - Start");
    
                const int SOD_NEED_TO_ORDER = 1;
                const int SOD_ON_ORDER = 2;
                const int SOD_IN_STOCK = 3;
                const int PO_RECEIVED = 4;
    
                Boolean bReturn = false;
                int iStatus = SOD_NEED_TO_ORDER; // Need To Order
    
                tracingService.Trace("In UpdateSalesOrderDetailWithPODetail - Retrieving salesOrderDetail gSalesOrderDetailID:" + gSalesOrderDetailID.ToString());
                
                // Get SalesOrderDetail by ID
    
                ColumnSet attributes = new ColumnSet(new string[] { "salesorderdetailid", "nstc_purchaseorder", "nstc_costperunit", "nstc_inventorystatus" });
                Entity salesOrderDetail = new Entity("salesorderdetail");
    
                salesOrderDetail = service.Retrieve(salesOrderDetail.LogicalName, gSalesOrderDetailID, attributes);
                tracingService.Trace("In UpdateSalesOrderDetailWithPODetail - updating salesOrderDetail nstc_purchaseorder");
    
                salesOrderDetail["nstc_purchaseorder"] = gPODetailID.ToString();
    
                tracingService.Trace("In UpdateSalesOrderDetailWithPODetail - updating salesOrderDetail nstc_costperunit");
    
                salesOrderDetail["nstc_costperunit"] = new Money(cCost);
                // Update Inventory Status
                if (istatusReason == PO_RECEIVED) // Received
                {
                    iStatus = SOD_IN_STOCK; // In Stock
                }
                else
                {
                    iStatus = SOD_ON_ORDER; // On Order
                }
                tracingService.Trace("In UpdateSalesOrderDetailWithPODetail - updating salesOrderDetail nstc_inventorystatus");
    
                salesOrderDetail["nstc_inventorystatus"] = new OptionSetValue(iStatus);
    
                tracingService.Trace("In UpdateSalesOrderDetailWithPODetail - serviceUpdate()");
                service.Update(salesOrderDetail);
    
                return bReturn;
            }
    

    Any ideas? Any help would be appreciated

    Tuesday, October 14, 2014 9:07 PM

All replies

  • Hello,

    Have you added CRM url under trusted sites ?? if not do that and then try to test.


    Microsoft Dynamics CRM Training|Our Blog | Follow US | Our Facebook Page | Microsoft Dynamics CRM 2011 Application Design
    Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.

    Wednesday, October 15, 2014 3:47 AM
    Moderator
  • Mahender:

    Yes, the CRM url is a trusted site in IE.

    Thursday, October 16, 2014 4:15 PM
  • I will suggest you to enable tracing in CRM and check for more details error as it's a generic error. also you can check if there is some information in event viewer.

    Microsoft Dynamics CRM Training|Our Blog | Follow US | Our Facebook Page | Microsoft Dynamics CRM 2011 Application Design
    Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.

    Friday, October 17, 2014 2:50 AM
    Moderator
  • Here is a condensed CRM Trace log; CRM keeps complaining about a missing entity map.

    >Web Service Plug-in failed in SdkMessageProcessingStepId: {27CBBB1B-EA3E-DB11-86A7-000A3A5473E8}; EntityName: none; Stage: 30; MessageName: InitializeFrom; AssemblyName: Microsoft.Crm.Extensibility.InternalOperationPlugin, Microsoft.Crm.ObjectModel, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35; ClassName: Microsoft.Crm.Extensibility.InternalOperationPlugin; Exception: Unhandled Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
       at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
       at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
       at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
       at System.Web.Services.Protocols.LogicalMethodInfo.Invoke(Object target, Object[] values)
       at Microsoft.Crm.Extensibility.InternalOperationPlugin.Execute(IServiceProvider serviceProvider)
       at Microsoft.Crm.Extensibility.V5PluginProxyStep.ExecuteInternal(PipelineExecutionContext context)
       at Microsoft.Crm.Extensibility.VersionedPluginProxyStepBase.Execute(PipelineExecutionContext context)
    Inner Exception: Microsoft.Crm.CrmException: There is no entity map defined for the given entities
       at Microsoft.Crm.ObjectModel.CustomizationService.InitializeFrom(BusinessEntityMoniker moniker, String targetEntityName, TargetFieldType targetFieldType, Boolean mapReadSecuredOnSourceAndTarget, ExecutionContext context)
       at Microsoft.Crm.ObjectModel.CustomizationService.InitializeFrom(BusinessEntityMoniker moniker, String targetEntityName, TargetFieldType targetFieldType, ExecutionContext context)
    .
    
    >Crm Exception: Message: There is no entity map defined for the given entities, ErrorCode: -2147217919, InnerException: Microsoft.Crm.CrmException: There is no entity map defined for the given entities
    
    >MessageProcessor fail to process message 'InitializeFrom' for 'none'.
    [2014-10-17 12:22:15.960] Process: w3wp |Organization:00000000-0000-0000-0000-000000000000 |Thread:   12 |Category: Exception |User: 00000000-0000-0000-0000-000000000000 |Level: Error |ReqId: 8974c3f8-1b11-40df-a1ce-b16819259b15 | CrmException..ctor  ilOffset = 0x7
    
    >Crm Exception: Message: There is no entity map defined for the given entities, ErrorCode: -2147217919
    [2014-10-17 12:22:15.960] Process: w3wp |Organization:9bd52553-d52d-4791-8120-dbfa8a8b0929 |Thread:   12 |Category: Application |User: 00000000-0000-0000-0000-000000000000 |Level: Error |ReqId: 8974c3f8-1b11-40df-a1ce-b16819259b15 | ErrorInformation.LogError  ilOffset = 0x17
    
    MSCRM Error Report:
    --------------------------------------------------------------------------------------------------------
    Error: There is no entity map defined for the given entities
    
    Error Number: 0x80040E01
    
    Error Message: There is no entity map defined for the given entities
    
    Error Details: There is no entity map defined for the given entities
    
    Source File: Not available
    
    Line Number: Not available
    
    Request URL: 
    
    Stack Trace Info: [CrmException: There is no entity map defined for the given entities]
       at Microsoft.Crm.Application.Platform.ServiceCommands.PlatformCommand.XrmExecuteInternal()
       at Microsoft.Crm.Application.Platform.ServiceCommands.InitializeFromCommand.Execute()
    
    
    >Crm Exception: Message: Regarding entity with object type 1088 does not have a relationship with object type 8001, ErrorCode: -2147220989, InnerException: System.ArgumentException: Regarding entity with object type 1088 does not have a relationship with object type 8001
    [2014-10-17 12:22:24.643] Process: w3wp |Organization:9bd52553-d52d-4791-8120-dbfa8a8b0929 |Thread:   12 |Category: Platform.Sdk |User: 13a89d9d-30bc-4969-9d06-2c381cc3f9a0 |Level: Error |ReqId: 141cdb53-02c0-4ab8-8605-3a74eb727480 | VersionedPluginProxyStepBase.Execute  ilOffset = 0x65

    Friday, October 17, 2014 4:36 PM
  • Behind the scenes CRM is attempting to initialize a new record using a map and an InitializeFrom message. The type codes in your error message indicate the problem relationship is from entity type 1088 (SalesOrder) to 8001 (PostRole).  Not seeing any type of relationship between these two entities that are visible (i.e. that you could actually edit and fix) I am at a loss.  I am guessing this is all native functionality so perhaps it is time to call MS Support.
    Friday, October 17, 2014 7:51 PM
  • Hi, MJordan 494, not sure if you'll get this nearly a year after your last post, but we've run into pretty much the same issue in on of our customer's CRM 2013 on-premise org.  Did you ever open a case with MS on this issue, and if so, would you mind sharing the outcome?

    Thanks!

    Thursday, July 2, 2015 6:02 PM