Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

There is no active transaction

(0) ShareShare
ReportReport
Posted on by 20

Hello Guys, 

when I try to create or update record from this plugin on realTime workflow that do the same job I get:

"There is no active transaction. This error is usually caused by custom plug-ins that ignore errors from service calls and continue processing"

using Innovation.Helper;
using Microsoft.Xrm.Sdk;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Innovation.PaymentEntity.RegularPayment
{
public class RegularPayment : IPlugin
{

public void Execute(IServiceProvider serviceProvider)
{
ITracingService tracingService = (ITracingService)serviceProvider.GetService(typeof(ITracingService));

IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
IOrganizationService service = serviceFactory.CreateOrganizationService(context.InitiatingUserId);
CrmDataHelper CRM = new CrmDataHelper(service);


if (context.PostEntityImages.Contains("Post") && context.PostEntityImages["Post"] is Entity)
{
//Entity Entity = new Entity();
var Entity = (Entity)context.PostEntityImages["Post"];
//var current = context.InputParameters["Target"];
//var PreEntity = (Entity)context.PreEntityImages["Post"];

tracingService.Trace("created the image object");
// Check current transactions
var CurrentTransactions = CRM.RetrieveMultiple("inn_transactions", new string[] { "inn_paymententity" }, new string[] { Entity.Id.ToString() }, new string[] { });

tracingService.Trace("current transactions " + CurrentTransactions);

if (CurrentTransactions == null)
{
// Create Payment reqular
if ((Entity.GetAttributeValue<OptionSetValue>("inn_paymentstatus").Value != 121370002) & (Entity.GetAttributeValue<OptionSetValue>("inn_paymenttype").Value == 121370000))
{ //PaymentStatus == Paid && PaymentType == autopayment
tracingService.Trace("will create transaction");
Entity Transaction = new Entity("inn_transactions");
Transaction["inn_paymententity"] = new EntityReference(Entity.LogicalName, Entity.Id);
Transaction["inn_dateofpayment"] = DateTime.Now;
Transaction["inn_amount"] = (Entity.GetAttributeValue<Money>("inn_amount") != null) ? new Money(Entity.GetAttributeValue<Money>("inn_amount").Value) : new Money(0);
Transaction["inn_checknumber"] = (Entity.GetAttributeValue<string>("inn_checknumber") != null) ? Entity.GetAttributeValue<string>("inn_checknumber") : "";
Transaction["inn_chequedate"] = (Entity.GetAttributeValue<DateTime>("inn_chequedate") != null) ? Entity.GetAttributeValue<DateTime>("inn_chequedate") : DateTime.Now;
tracingService.Trace("just before execute create ");
CRM.CreateEntity(Transaction);
tracingService.Trace("created transaction");

tracingService.Trace("create payment regular");
var CurrentPaymentEntity = new Entity(Entity.LogicalName, Entity.Id);
CurrentPaymentEntity.Id = Entity.Id;
tracingService.Trace("current record " + CurrentPaymentEntity.LogicalName + " " + CurrentPaymentEntity.Id + " this is the id");
CurrentPaymentEntity["inn_paymentstatus"] = new OptionSetValue(121370002);
try { service.Update(CurrentPaymentEntity); }
catch (Exception ex) { throw new InvalidPluginExecutionException("error in update " + ex); } //it stucks here!!
//CRM.UpdateEntity(CurrentPaymentEntity);
tracingService.Trace("updated current entity");
}
}
}
else
{
throw new InvalidPluginExecutionException("doesn't contain image!!");
}
}
}
}

the error log

Unhandled exception:
Exception type: System.ServiceModel.FaultException`1[Microsoft.Xrm.Sdk.OrganizationServiceFault]
Message: There is no active transaction. This error is usually caused by custom plug-ins that ignore errors from service calls and continue processing.Detail:
<OrganizationServiceFault xmlns:i="">www.w3.org/.../XMLSchema-instance" xmlns="">schemas.microsoft.com/.../Contracts">
<ActivityId>2b2983ac-def1-431b-af37-cef4c4a1f479</ActivityId>
<ErrorCode>-2147220911</ErrorCode>
<ErrorDetails xmlns:d2p1="">schemas.datacontract.org/.../System.Collections.Generic">
<KeyValuePairOfstringanyType>
<d2p1:key>ApiExceptionSourceKey</d2p1:key>
<d2p1:value xmlns:d4p1="">www.w3.org/.../XMLSchema" i:type="d4p1:string">Plugin/Microsoft.Crm.ObjectModel.CustomBusinessEntityService</d2p1:value>
</KeyValuePairOfstringanyType>
<KeyValuePairOfstringanyType>
<d2p1:key>ApiOriginalExceptionKey</d2p1:key>
<d2p1:value xmlns:d4p1="">www.w3.org/.../XMLSchema" i:type="d4p1:string">Microsoft.Crm.CrmException: There is no active transaction. This error is usually caused by custom plug-ins that ignore errors from service calls and continue processing. ---&gt; Microsoft.Crm.CrmException: There is no active transaction. This error is usually caused by custom plug-ins that ignore errors from service calls and continue processing.
at Microsoft.Crm.CrmTransaction.CommitTransaction()
at Microsoft.Crm.LegacySqlDataAccessContextImplementation.CommitTransaction()
at Microsoft.Crm.Extensibility.MessageProcessor.Execute(PipelineExecutionContext context)
at Microsoft.Crm.Extensibility.InternalMessageDispatcher.Execute(PipelineExecutionContext context)
at Microsoft.Crm.Extensibility.ExtensiblePlatformMessageDispatcher.Execute(PipelineExecutionContext pluginContext)
at Microsoft.Crm.Extensibility.ExtensiblePlatformMessageDispatcher.UpdateWithInvocationSource(BusinessEntity entity, FilterExpression filter, Int32 invocationSource, ExecutionContext context)
at Microsoft.Crm.Extensibility.ExtensiblePlatformMessageDispatcher.Update(BusinessEntity entity, FilterExpression filter, ExecutionContext context)
at Microsoft.Crm.BusinessEntities.BusinessProcessObject.&lt;&gt;c__DisplayClass199_0.&lt;UpdateWithPipelineAndExtensions&gt;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.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)
--- End of inner exception stack trace ---
at Microsoft.Crm.Extensibility.VersionedPluginProxyStepBase.Execute(PipelineExecutionContext context)
at Microsoft.Crm.Extensibility.PipelineInstrumentationHelper.Execute(Boolean instrumentationEnabled, String stopwatchName, ExecuteWithInstrumentation action, PipelineExecutionContext context)
at Microsoft.Crm.Extensibility.Pipeline.&lt;&gt;c__DisplayClass2_1.&lt;Execute&gt;b__0()</d2p1:value>
</KeyValuePairOfstringanyType>
<KeyValuePairOfstringanyType>
<d2p1:key>ApiStepKey</d2p1:key>
<d2p1:value xmlns:d4p1="">www.w3.org/.../XMLSchema" i:type="d4p1:string">fb0227d4-37c2-e811-a94d-000d3aba6816</d2p1:value>
</KeyValuePairOfstringanyType>
<KeyValuePairOfstringanyType>
<d2p1:key>ApiDepthKey</d2p1:key>
<d2p1:value xmlns:d4p1="">www.w3.org/.../XMLSchema" i:type="d4p1:string">3</d2p1:value>
</KeyValuePairOfstringanyType>
<KeyValuePairOfstringanyType>
<d2p1:key>ApiActivityIdKey</d2p1:key>
<d2p1:value xmlns:d4p1="">www.w3.org/.../XMLSchema" i:type="d4p1:string">59d41de1-ccd8-42f1-bfe6-fd3e4da170f2</d2p1:value>
</KeyValuePairOfstringanyType>
<KeyValuePairOfstringanyType>
<d2p1:key>ApiPluginSolutionNameKey</d2p1:key>
<d2p1:value xmlns:d4p1="">www.w3.org/.../XMLSchema" i:type="d4p1:string">System</d2p1:value>
</KeyValuePairOfstringanyType>
<KeyValuePairOfstringanyType>
<d2p1:key>ApiStepSolutionNameKey</d2p1:key>
<d2p1:value xmlns:d4p1="">www.w3.org/.../XMLSchema" i:type="d4p1:string">System</d2p1:value>
</KeyValuePairOfstringanyType>
</ErrorDetails>
<Message>There is no active transaction. This error is usually caused by custom plug-ins that ignore errors from service calls and continue processing.</Message>
<Timestamp>2019-07-03T12:25:31.9321853Z</Timestamp>
<ExceptionRetriable>false</ExceptionRetriable>
<ExceptionSource i:nil="true" />
<InnerFault i:nil="true" />
<OriginalException i:nil="true" />
<TraceText>

[Innovation.PaymentEntity.RegularPayment: Innovation.PaymentEntity.RegularPayment.RegularPayment]
[881c6fac-8b9d-e911-a81d-000d3ab35b39: Innovation.PaymentEntity.RegularPayment.RegularPayment: Update of inn_paymententity]
created the image object
current transactions
will create transaction
just before execute create


[Innovation.Transaction.Payment: Innovation.Transaction.Payment.Payment]
[df1b9779-832f-e811-a955-000d3a209848: Innovation.Transaction.Payment.Payment: Create of inn_transactions]

</TraceText>
</OrganizationServiceFault>

*This post is locked for comments

  • RE: There is no active transaction

    Hi, I get some error when closing my incident. I researched and found problem. Problem is that customer of incident has no name. I update name of customer and try again and finally ı could close my incident

  • Suggested answer
    Nflannery Profile Picture
    Nflannery 360 on at
    RE: There is no active transaction

    Take out the Try/Catch blocks.  That will resolve this.

  • Suggested answer
    Kalpavruksh D365 CoE Profile Picture
    Kalpavruksh D365 CoE 2,545 on at
    RE: There is no active transaction

    Hi,

    You can check the following links to get possible solutions:
    1. andz88.wordpress.com/.../
    2. community.dynamics.com/.../plugin-error-no-active-transactions

    We have encountered this error as we were assigning the same record using sync workflow which was sending an email using custom activity by adding team members as CC of an email. Hence please check if you have registered any workflows and if those are failing at any step.

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,494 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,305 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans