Skip to main content

Notifications

Customer experience | Sales, Customer Insights,...
Answered

Plugin call Action Error "New transaction is not allowed because there are other threads running in the session"

Posted on by 87

Hi,

I have Dynamics 365 V8.2 on-premise and I have sometimes an error "New transaction is not allowed because there are other threads running in the session" inside an asyn plugin when its calling an action.

1. I have an custom action based on account entity which will call SAP api to send crm account info to SAP

2. I have an async plugin trigged by updating a custom entity and then, it will update the a field on account entity and then call action in step 1 to send updated account infomation to sap. but sometimes , this plugin failed to execute with an error "New transaction is not allowed because there are other threads running in the session", and this error was threw when calling the action. it is very strange for me. this problem happened serveral times daily, abount 15%-30%.

3. I have a workflow which call the action in step 1, when the pluign failed to send info to sap, I will run this workflow manually and this workflows always works well, without any error.

I have searched a lot and this error and I can not found any useful information. I have also add 3 times retry today but it does has 3 times failed with the same error.

Thank you.

  • Song Profile Picture
    Song 87 on at
    RE: Plugin call Action Error "New transaction is not allowed because there are other threads running in the session"

    Hi David,

    Maybe your first point explains my problem. I found that I have put a static IOrganizationService outside the Execute Method.

    I should put the instance of IOrganizationService inside the Execute  method and pass as an parameter to another method. Am I right?

    Thank you and I will try it.

  • Verified answer
    David Jennaway Profile Picture
    David Jennaway 14,063 on at
    RE: Plugin call Action Error "New transaction is not allowed because there are other threads running in the session"

    There are a couple of things to check in your code:

    Do you use the IOrganizationService instance that is derived from the IPluginExecutionContext for all calls to CRM ? If you use a different method to access CRM in your plugin, you could cause issues as this would be considered a new connection and new transaction. If possible, you should always use the IOrganizationService instance that is derived from the IPluginExecutionContext.

    Do you make any calls to access or modify metadata in the plugin ? Metadata operations, especially when modifying metadata, run under a different SQL concurrency level, and this can cause issues. However, you normally get a different error in this scenario

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!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans