{"id":39940,"date":"2024-12-10T12:46:15","date_gmt":"2024-12-10T07:16:15","guid":{"rendered":"https:\/\/www.inogic.com\/blog\/?p=39940"},"modified":"2025-01-17T14:06:18","modified_gmt":"2025-01-17T08:36:18","slug":"leveraging-newrecord-and-oldrecord-in-low-code-plug-ins-for-dataverse","status":"publish","type":"post","link":"https:\/\/www.inogic.com\/blog\/2024\/12\/leveraging-newrecord-and-oldrecord-in-low-code-plug-ins-for-dataverse\/","title":{"rendered":"Leveraging NewRecord and OldRecord in Low-Code Plug-Ins for Dataverse"},"content":{"rendered":"<p><img decoding=\"async\" class=\"alignnone size-full wp-image-39947\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2024\/12\/Dataverse.png\" alt=\"Dataverse\" width=\"1925\" height=\"1100\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2024\/12\/Dataverse.png 1925w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2024\/12\/Dataverse-300x171.png 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2024\/12\/Dataverse-1024x585.png 1024w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2024\/12\/Dataverse-768x439.png 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2024\/12\/Dataverse-1536x878.png 1536w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2024\/12\/Dataverse-660x377.png 660w\" sizes=\"(max-width: 1925px) 100vw, 1925px\" \/><\/p>\n<p><a href=\"https:\/\/www.inogic.com\/services\/#powerplatform\" target=\"_blank\" rel=\"noopener\">Microsoft Dataverse<\/a> offers low-code plug-ins to simplify the creation and management of event-driven workflows. Unlike traditional plug-ins that require custom .NET code and manual registration, low-code plug-ins are managed directly within Dataverse. These plug-ins use the Power Fx expression language to define their behaviour, enabling users to build complex workflows with minimal coding.<\/p>\n<p>In this blog, we will see how we can use OldRecord and NewRecord in Low-Code Plugins in Dataverse. As the name describes, the &#8220;OldRecord&#8221; is used to store the attribute values which were present before saving the record and the &#8220;NewRecord&#8221; is used to store the attribute values which were present after saving the record.<\/p>\n<p><strong>Scenario: Prevent a user from decreasing the Credit Limit field value on an Account entity below its previous value<\/strong><\/p>\n<p>In many business systems, the Credit Limit field on an Account entity is a critical financial field that determines the maximum amount of credit a customer can use. For this example, we will ensure that the Credit Limit field cannot be decreased below its previous value. If a user tries to decrease the Credit Limit, the update will be blocked, and an error will be shown.<\/p>\n<p>Let\u2019s walk through how we can achieve this using a Low-Code Plugin in Dataverse.<\/p>\n<p><strong>Develop an automated plugin with the Dataverse Accelerator App<\/strong><\/p>\n<p>The automated plugin is triggered by events on Dataverse tables, such as create, update, and delete actions.<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-39942\" style=\"border: 1px solid #000000; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2024\/12\/1Low-Code-Plug-Ins-for-Dataverse.png\" alt=\"Low-Code Plug-Ins for Dataverse\" width=\"662\" height=\"698\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2024\/12\/1Low-Code-Plug-Ins-for-Dataverse.png 662w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2024\/12\/1Low-Code-Plug-Ins-for-Dataverse-285x300.png 285w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2024\/12\/1Low-Code-Plug-Ins-for-Dataverse-660x696.png 660w\" sizes=\"(max-width: 662px) 100vw, 662px\" \/><\/p>\n<h3><strong>Plugin Configuration:<\/strong><\/h3>\n<ul>\n<li><strong>Display Name:<\/strong> Provide a descriptive name for your plugin, such as &#8220;Prevent Credit Limit Decrease on Accounts.&#8221;<\/li>\n<li><strong>Table:<\/strong> Select the <strong>Accounts<\/strong> table, as we want this logic to apply to the <strong>Account<\/strong><\/li>\n<li><strong>Run this plug-in rule when the row is<\/strong>:\u00a0Choose <strong>Update<\/strong> from the list of data events. This will ensure the plugin runs when an Account is updated.<\/li>\n<li><strong>Expression: <\/strong>Enter the following Power Fx expression in the <strong>Expression editor<\/strong>:<\/li>\n<\/ul>\n<pre class=\"lang:css gutter:true start:1\">If(\r\n\r\n!IsBlank(OldRecord.'Credit Limit') &amp;&amp; !IsBlank(NewRecord.'Credit Limit') &amp;&amp; NewRecord.'Credit Limit' &lt; OldRecord.'Credit Limit',\r\n\r\nTrace(\"Credit Limit is being decreased from \" &amp; Text(OldRecord.'Credit Limit') &amp; \" to \" &amp; Text(NewRecord.'Credit Limit'));\r\n\r\nError(\"The Credit Limit cannot be lowered. Please enter a value greater than or equal to the previous limit.\")\r\n\r\n)<\/pre>\n<ul>\n<li><strong>Advanced Options <\/strong><\/li>\n<\/ul>\n<ol>\n<li><strong>Solut<\/strong><strong>ion<\/strong>: Select the solution where you want to save the plugin.<\/li>\n<li><strong>When It Should Run:<\/strong> Choose whether this plugin should run during the <strong>Pre-operation<\/strong> or <strong>Post-operation<\/strong> For this scenario, it&#8217;s best to select <strong>Pre-operation<\/strong> so the check happens before the data is saved to the database.<\/li>\n<\/ol>\n<p>As per our expression, if a user tries to update an Account and reduce the Credit Limit, the plugin will raise an error and prevent the update from being saved. If the credit limit is not decreased, the update will proceed normally.<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-39943\" style=\"border: 1px solid #000000; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2024\/12\/2Low-Code-Plug-Ins-for-Dataverse.png\" alt=\"Low-Code Plug-Ins for Dataverse\" width=\"1645\" height=\"724\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2024\/12\/2Low-Code-Plug-Ins-for-Dataverse.png 1645w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2024\/12\/2Low-Code-Plug-Ins-for-Dataverse-300x132.png 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2024\/12\/2Low-Code-Plug-Ins-for-Dataverse-1024x451.png 1024w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2024\/12\/2Low-Code-Plug-Ins-for-Dataverse-768x338.png 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2024\/12\/2Low-Code-Plug-Ins-for-Dataverse-1536x676.png 1536w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2024\/12\/2Low-Code-Plug-Ins-for-Dataverse-660x290.png 660w\" sizes=\"(max-width: 1645px) 100vw, 1645px\" \/><\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-39944\" style=\"border: 1px solid #000000; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2024\/12\/3Low-Code-Plug-Ins-for-Dataverse.png\" alt=\"Low-Code Plug-Ins for Dataverse\" width=\"1652\" height=\"782\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2024\/12\/3Low-Code-Plug-Ins-for-Dataverse.png 1652w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2024\/12\/3Low-Code-Plug-Ins-for-Dataverse-300x142.png 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2024\/12\/3Low-Code-Plug-Ins-for-Dataverse-1024x485.png 1024w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2024\/12\/3Low-Code-Plug-Ins-for-Dataverse-768x364.png 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2024\/12\/3Low-Code-Plug-Ins-for-Dataverse-1536x727.png 1536w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2024\/12\/3Low-Code-Plug-Ins-for-Dataverse-660x312.png 660w\" sizes=\"(max-width: 1652px) 100vw, 1652px\" \/><\/p>\n<p>To monitor the plugin&#8217;s behaviour, we can view the logs in the <strong>Plugin Monitoring<\/strong> section of Dataverse. This allows you to see which records triggered the plugin and whether the logic was applied successfully.<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-39945\" style=\"border: 1px solid #000000; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2024\/12\/4Low-Code-Plug-Ins-for-Dataverse.png\" alt=\"Low-Code Plug-Ins for Dataverse\" width=\"1917\" height=\"837\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2024\/12\/4Low-Code-Plug-Ins-for-Dataverse.png 1917w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2024\/12\/4Low-Code-Plug-Ins-for-Dataverse-300x131.png 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2024\/12\/4Low-Code-Plug-Ins-for-Dataverse-1024x447.png 1024w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2024\/12\/4Low-Code-Plug-Ins-for-Dataverse-768x335.png 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2024\/12\/4Low-Code-Plug-Ins-for-Dataverse-1536x671.png 1536w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2024\/12\/4Low-Code-Plug-Ins-for-Dataverse-660x288.png 660w\" sizes=\"(max-width: 1917px) 100vw, 1917px\" \/><\/p>\n<p>In Plugin Monitoring, enabling all logs captures all trace messages, while exceptions only log errors. These settings can be adjusted in plugin registration and viewed under Plugin Monitoring in the Power Platform Admin Center.<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-39946\" style=\"border: 1px solid #000000; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2024\/12\/5Low-Code-Plug-Ins-for-Dataverse.png\" alt=\"Low-Code Plug-Ins for Dataverse\" width=\"1883\" height=\"784\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2024\/12\/5Low-Code-Plug-Ins-for-Dataverse.png 1883w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2024\/12\/5Low-Code-Plug-Ins-for-Dataverse-300x125.png 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2024\/12\/5Low-Code-Plug-Ins-for-Dataverse-1024x426.png 1024w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2024\/12\/5Low-Code-Plug-Ins-for-Dataverse-768x320.png 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2024\/12\/5Low-Code-Plug-Ins-for-Dataverse-1536x640.png 1536w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2024\/12\/5Low-Code-Plug-Ins-for-Dataverse-660x275.png 660w\" sizes=\"(max-width: 1883px) 100vw, 1883px\" \/><\/p>\n<h2><strong>Conclusion<\/strong><\/h2>\n<p><strong>OldRecord<\/strong> and <strong>NewRecord<\/strong> in low-code plugins make it easy to validate data changes and maintain consistency with minimal coding effort.<\/p>\n<p><a href=\"https:\/\/www.inogic.com\/services\/?utm_source=inogic-t-blog&amp;utm_medium=powerplatform&amp;utm_campaign=itblog&amp;utm_id=powerplatform\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" class=\"alignnone wp-image-36464\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/11\/Discover-How-Inogics-Power-Platform-Services-Can-Help-You-Harness-the-Power-of-Low-Code-with-Microsoft-Power-Platform.-1.png\" alt=\"Microsoft Power Platform\" width=\"735\" height=\"210\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/11\/Discover-How-Inogics-Power-Platform-Services-Can-Help-You-Harness-the-Power-of-Low-Code-with-Microsoft-Power-Platform.-1.png 700w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/11\/Discover-How-Inogics-Power-Platform-Services-Can-Help-You-Harness-the-Power-of-Low-Code-with-Microsoft-Power-Platform.-1-300x86.png 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/11\/Discover-How-Inogics-Power-Platform-Services-Can-Help-You-Harness-the-Power-of-Low-Code-with-Microsoft-Power-Platform.-1-660x189.png 660w\" sizes=\"(max-width: 735px) 100vw, 735px\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Microsoft Dataverse offers low-code plug-ins to simplify the creation and management of event-driven workflows. Unlike traditional plug-ins that require custom .NET code and manual registration, low-code plug-ins are managed directly within Dataverse. These plug-ins use the Power Fx expression language to define their behaviour, enabling users to build complex workflows with minimal coding. In this\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.inogic.com\/blog\/2024\/12\/leveraging-newrecord-and-oldrecord-in-low-code-plug-ins-for-dataverse\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":15,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[2354],"tags":[3080],"class_list":["post-39940","post","type-post","status-publish","format-standard","hentry","category-dataverse","tag-microsoft-dataverse"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/39940","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/users\/15"}],"replies":[{"embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/comments?post=39940"}],"version-history":[{"count":0,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/39940\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/media?parent=39940"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/categories?post=39940"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/tags?post=39940"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}