<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Prakash Kalimuthu</title>
    <description>The latest articles on DEV Community by Prakash Kalimuthu (@prakash_4691).</description>
    <link>https://dev.to/prakash_4691</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F99mvlsfu5tfj9m7ku25d.png</url>
      <title>DEV Community: Prakash Kalimuthu</title>
      <link>https://dev.to/prakash_4691</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/prakash_4691"/>
    <language>en</language>
    <item>
      <title>Dataverse PreValidation Doesn't Always Run Outside the Transaction: Check IsInTransaction</title>
      <dc:creator>Prakash Kalimuthu</dc:creator>
      <pubDate>Mon, 23 Nov 2026 23:55:38 +0000</pubDate>
      <link>https://dev.to/prakash_4691/dataverse-prevalidation-doesnt-always-run-outside-the-transaction-check-isintransaction-5em6</link>
      <guid>https://dev.to/prakash_4691/dataverse-prevalidation-doesnt-always-run-outside-the-transaction-check-isintransaction-5em6</guid>
      <description>&lt;p&gt;Kept thinking &lt;strong&gt;PreValidation&lt;/strong&gt; always runs outside the database transaction in Dataverse.&lt;/p&gt;

&lt;p&gt;Then I tested the same Account Create plugin through two paths.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Direct API create:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;PreValidation, Stage 10: &lt;code&gt;IsInTransaction = False&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;PreOperation, Stage 20: &lt;code&gt;IsInTransaction = True&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;PostOperation (sync mode), Stage 40: &lt;code&gt;IsInTransaction = True&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Model-driven app form save with change set (BPF attached to the table):&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;PreValidation, Stage 10: &lt;code&gt;IsInTransaction = True&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;PreOperation, Stage 20: &lt;code&gt;IsInTransaction = True&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;PostOperation (sync mode), Stage 40: &lt;code&gt;IsInTransaction = True&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Same table. Same message. Same registered steps.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The difference is the caller path and whether the pipeline already has a transaction active when it reaches PreValidation.&lt;/p&gt;

&lt;p&gt;That is why Stage alone is not enough. &lt;code&gt;IPluginExecutionContext.IsInTransaction&lt;/code&gt; tells you what actually matters for that execution.&lt;/p&gt;

&lt;p&gt;PreValidation usually runs before the main transaction, but it can run inside an existing transaction when another operation initiates it. A model-driven app form save can follow a different platform path from a plain Web API create.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;This also matters for error handling.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When &lt;code&gt;context.IsInTransaction&lt;/code&gt; is true and the plugin throws an exception, Dataverse rolls back the work in that active transaction.&lt;/p&gt;

&lt;p&gt;So in the model-driven app save, an exception thrown at PreValidation was already inside a transaction. In the direct create, PreValidation was outside the transaction, but by PreOperation the work was inside it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;One small clarification:&lt;/strong&gt; not every caught error causes a rollback. The exception has to reach the platform. If your code handles it and completes normally, Dataverse treats the step as successful.&lt;/p&gt;

&lt;p&gt;The practical lesson is simple:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Don't assume. Check &lt;code&gt;context.IsInTransaction&lt;/code&gt;.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;If your plugin has logic that depends on transaction behavior, branch on the runtime value, not on the stage name.&lt;/p&gt;

</description>
      <category>powerplatform</category>
      <category>dataverse</category>
      <category>microsoftdynamics365</category>
      <category>developertips</category>
    </item>
  </channel>
</rss>
