Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Exception throwing on Association request of N:N relationship in Plugin

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

I have setup N:N relationship between Account and System User and making an association in the plugin during Update and Create of account. Plugin works as expected when I create an account / update the account manually. but plugin throws exception during the SSIS job execution.

Below is the stack trace I am getting on execution of Service.Associate method in Plugin. The issue is that there is no error in the stack trace and not able to find out the root cause.

Server stack trace: 

at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

Exception rethrown at [0]: 
at Microsoft.Crm.Sandbox.SandboxOrganizationService.Execute(String operation, Byte[] serializedRequest, Object sandboxTraceSettingsObj)
at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs)
at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg)

Exception rethrown at [1]: 
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at Microsoft.Crm.Sandbox.ISandboxOrganizationService.Execute(String operation, Byte[] serializedRequest, Object traceSettings)
at Microsoft.Crm.Sandbox.SandboxOrganizationServiceWrapper.ExecuteInternal(OrganizationRequest request)
at Microsoft.Crm.Sandbox.SandboxOrganizationServiceWrapper.AssociateInternal(String entityName, Guid entityId, Relationship relationship, EntityReferenceCollection relatedEntities)
at Microsoft.Crm.Sandbox.SandboxOrganizationServiceWrapper.Associate(String entityName, Guid entityId, Relationship relationship, EntityReferenceCollection relatedEntities)
at Empired.Gerard.Crm.Plugins.Orion_AccountOwner_onCreate.Execute(IServiceProvider serviceProvider)

*This post is locked for comments

  • Verified answer
    a33ik Profile Picture
    a33ik 84,323 Most Valuable Professional on at
    RE: Exception throwing on Association request of N:N relationship in Plugin

    Hello,

    It seems that relationship already exists when your plugin is called. You should add a validation before Association - if relationship already exists then just quit plugin. Otherwise - associate records.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Exception throwing on Association request of N:N relationship in Plugin

    I think I found the issue but not able to figured out the reason of throwing this error. See the error below. 

    663826.Capture.PNG

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Exception throwing on Association request of N:N relationship in Plugin

    Yes. this is what I have got after enabling the trace.

  • Aric Levin Profile Picture
    Aric Levin 30,188 on at
    RE: Exception throwing on Association request of N:N relationship in Plugin

    Can you enable Plugin Trace Log and let us know if you get any exceptions there?

    Go to Settings -> Administration -> System Settings -> Customization, and select the plugin exception option to exception or all.

    Then rerun your process and check if there are anything is logged in the Plugin Trace Log.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Exception throwing on Association request of N:N relationship in Plugin

    No. I am using Dynamics CRM 2016 Online.

  • Aric Levin Profile Picture
    Aric Levin 30,188 on at
    RE: Exception throwing on Association request of N:N relationship in Plugin

    I am with Alex on this. Possibly an issue with the user account.

    If the tracing does not give you what you are looking for, and since you are on-prem, you can install Visual Studio Remote Debugging tools on the CRM Server, and attach your plugin to the w3wp process on the CRM Server.

    Hope this helps.

  • ashlega Profile Picture
    ashlega 34,475 on at
    RE: Exception throwing on Association request of N:N relationship in Plugin

    Just guessing, but maybe that ownerid is incorrect somehow? Could it be a team?

    Either way, it seems you are on-prem, so you might try enabling tracing to see what shows up in the logs:

    technet.microsoft.com/.../hh699694.aspx

    Also, you have try-catch there.. Are you logging those exceptions in the trace service? Anything interesting there?

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Exception throwing on Association request of N:N relationship in Plugin

    Thanks for your response. that is the main issue that it is not showing any error. just a stack trace. I can definitely share the code. 

    313081.Capture.PNG

  • Aric Levin Profile Picture
    Aric Levin 30,188 on at
    RE: Exception throwing on Association request of N:N relationship in Plugin

    Can you share your code where you are tying to associated the account?

    Can't see anything from the error except of where it occurs.

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,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,253 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans