I recently started working with plugins in CRM 2011, and I ran into problems with plugins registered in the Create message as Post-Operation.
When I register creation as a post-operation, I expect that when I delete the plugin code, the object is already created in the database, and I would have to create a related object (linked to the newly created object using a foreign key) in the plugin. But when I create a linked object and update it and say SaveChanges (), it gives me a Microsoft.Xrm.SaveChangesException "Error processing this request"
And if I move on to the internal exception, it just points to OrganizationServiceFault. The stack trace shows:
Server stack trace: in System.ServiceModel.Channels.ServiceChannel.HandleReply (operation ProxyOperationRuntime, ProxyRpc & rpc) in System.ServiceModel.Channels.ServiceChannel.Call (String action, Boolean oneway, ProxyOperationRuntime operation Object,] outs, TimeSpan timeout) in System.ServiceModel.Channels.ServiceChannelProxy.InvokeService (IMethodCallMessageCall, ProxyOperationRuntime method) in System.ServiceModel.Channels.ServiceChannelProxy.Invoke (message with message)
Exception thrown at [0]: in System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage (IMessage reqMsg, IMessage retMsg) in System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke (MessageData & msgData in Microsoft Int32 .Xrm.Sdk.IOrganizationService.Execute (OrganizationRequest request) at Microsoft.Xrm.Sdk.Client.OrganizationServiceProxy.ExecuteCore (OrganizationRequest request) at Microsoft.Xrm.Sdk.Client.OrganizationServiceContext.Execute (OrganizationRequest request) at Microsoft.Xrm.Sdk .Client.OrganizationServiceContext.SaveChange (OrganizationRequest request, IList`1 results
I encounter this problem only when creating a message, if I do the same action when updating or deleting, it works fine. Has anyone encountered this problem? Please provide some materials that I can try to solve this problem. Thanks in advance!
Also, here is my plugin code.
The plugin starts when the ct_repcode object is created, and then in my plugin I create the ct_repcodeMember object, which has a ct_repcodeid field that refers to the real ct_repcode object.
Entity repcodeEntity = _context.InputParameters["Target"] as Entity; Guid repcodeId = repcodeEntity.Id;