<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Federico Jousset on Medium]]></title>
        <description><![CDATA[Stories by Federico Jousset on Medium]]></description>
        <link>https://medium.com/@fedejousset?source=rss-2e0507c8681b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*Dnbwk_xwkZC7wkvR.</url>
            <title>Stories by Federico Jousset on Medium</title>
            <link>https://medium.com/@fedejousset?source=rss-2e0507c8681b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 01:01:54 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@fedejousset/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Dynamics 365 Web API Postman Collection]]></title>
            <link>https://medium.com/capgemini-microsoft-team/dynamics-365-web-api-postman-collection-abfb259f9eae?source=rss-2e0507c8681b------2</link>
            <guid isPermaLink="false">https://medium.com/p/abfb259f9eae</guid>
            <category><![CDATA[dynamics-365]]></category>
            <category><![CDATA[dynamics-crm]]></category>
            <category><![CDATA[microsoft]]></category>
            <dc:creator><![CDATA[Federico Jousset]]></dc:creator>
            <pubDate>Mon, 17 Sep 2018 14:47:31 GMT</pubDate>
            <atom:updated>2018-09-17T14:47:31.770Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*knbLtpWWuiPDfwaqeGqY1g.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/photos/2xaF4TbjXT0?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Jonas Jacobsson</a> on <a href="https://unsplash.com/?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>I started to use <a href="https://www.getpostman.com/">Postman</a> probably four years ago and it immediately became the only reason why this Firefox fanboy began to use Chrome (it was first developed as a Chrome App). A lot has changed with Postman since those old days, but it’s still is extremely useful while developing or testing API’s.</p><p>I was pleased when Microsoft recently added the <a href="https://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/webapi/use-postman-web-api">Use Postman with Web API</a> section to the documentation but it’s not widely known so I’ve created a custom Postman collection (<a href="https://www.getpostman.com/docs/v6/postman/environments_and_globals/manage_environments">environment</a> and <a href="https://www.getpostman.com/docs/v6/postman/collections/intro_to_collections">collection </a>with sample requests) to simplify the process.</p><h3>Prerequisites</h3><p>To use this collection, you need to <a href="https://www.getpostman.com/">download and install Postman</a> and also register an Azure Active Directory Application to connect and authenticate user accounts. If you haven’t done this before, follow this <a href="https://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/walkthrough-register-dynamics-365-app-azure-active-directory">walk-through</a> making sure that <em>Implicit Authentication</em> is enabled (this can be done updating the Application manifest once created):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VqCHFqpRiofvDDQyMjch0w.png" /><figcaption>Updating manifest to allow OAuth Implicit Flow</figcaption></figure><h3>Importing/Configuring D365 Web API Collection</h3><p>The first step is to <a href="https://github.com/fedejousset/Dynamics365WebApiPostmanCollection">download and import</a> the Dynamics 365 Web API collection using the <em>Run in Postman</em> button from its <a href="https://github.com/fedejousset/Dynamics365WebApiPostmanCollection">GitHub repository</a>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vpbZ2oXOULjPtEIxeIhVUg.png" /><figcaption>Use the <strong>Run In Postman</strong> button to download the collection</figcaption></figure><p>This button will open Postman and import the “<em>Dynamics 365 CE Web API</em>” collection and the “<em>Dynamics 365 Environment (Online)</em>”:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NL_EKS-4_-XjjDeXeuoKHA.png" /><figcaption>Collection and Environment imported</figcaption></figure><p>Once imported, you need to configure the environment to connect to your Dynamics 365 instance updating the required <a href="https://www.getpostman.com/docs/v6/postman/environments_and_globals/variables">environment variables</a>:</p><ul><li><strong>ApplicationId</strong>: Azure Application ID used to authenticate the user (variable format: <em>9f0e560f-4f2e-4a56-afb8-af72f9f20d06</em>)</li><li><strong>RedirectUrl</strong>: Redirect URL configured in the Azure AD Application (variable format: <em>https://localhost</em>)</li><li><strong>Resource</strong>: Dynamics 365 Organization that has been configured in the AAD Application Delegated Permissions section (variable format: <em>https://yourorg.crm4.dynamics.com</em>)</li></ul><p>To update these values, please follow the steps described in the image:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zXMLD6AuB5n1G34qNLYZoA.png" /><figcaption>Update environment variables</figcaption></figure><h3>Using the D365 Web API Collection</h3><p>The collection contains 40+ template requests to allow you to quickly compose and test your own requests. These templates are split in the following six folders:</p><ul><li><strong>Basic Operations </strong>(Create, Update, Delete)</li><li><strong>Retrieve Operations</strong> (Retrieve, Retrieve Multiple, Change Tracking)</li><li><strong>Batch Operations</strong></li><li><strong>Functions</strong> (Bound/unbound functions with/without parameters)</li><li><strong>Actions </strong>(Bound/unbound actions with/without parameters)</li><li><strong>Metadata</strong> (Retrieve entity/attribute metadata)</li></ul><p>Before executing any of these requests, you need to authenticate yourself against the Dynamics 365 instance:</p><ol><li>Click on the ellipses <em>(…)</em> next to the collection and select “Edit”:</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/379/1*sHXIqU5Mb3tZj2fiktb44g.png" /></figure><p>2. Select the <em>Authorization</em> tab<br>3. Click <em>the Get New Access Token</em> button<br>4. Complete authentication settings and click the <em>Request Token</em> button. Note that environment variables (showed in orange in the image) are being used here meaning you can use the same collection to connect to multiple environments:</p><ul><li><strong>Grant Type:</strong> Implicit</li><li><strong>Callback URL:</strong> {{RedirectUrl}}</li><li><strong>Auth URL:</strong> <a href="https://login.microsoftonline.com/common/oauth2/authorize?resource={{Resource}}">https://login.microsoftonline.com/common/oauth2/authorize?resource={{Resource}}</a></li><li><strong>Client ID:</strong> {{ApplicationId}}</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/519/1*fm9yRLrFZj8k2KkDyifqhw.png" /><figcaption>Authentication settings</figcaption></figure><p>5. Postman will show the Microsoft login page. Enter your credentials.<br>6. The access token and the expiration time (in minutes) will be displayed. Scroll down and click the <em>Use Token</em> button:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/722/1*Lt1c3btWl_AebEqmx4Kzpw.png" /></figure><p>7. Click the <em>Update </em>button to close the Authentication window and save the token</p><p>Once the token has been saved, all the template requests will inherit it from the collection. At this point, you can proceed to execute one of the sample requests to verify that everything is working by selecting it and clicking the <em>Send </em>button and review the response:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Chm2MaSfX0gW49YP22pHAw.png" /></figure><p>I know it feels like a lot of steps, but once you get familiar with the authentication process you will be able to do it in just a few seconds:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/1*_dxcW5tmRUsEDv0bf7rtAQ.gif" /><figcaption>Full authentication process</figcaption></figure><p>After getting a successful response you’re ready to start playing around with the sample requests or create your owns. Please remember that the access token will expire after one hour (unless configured otherwise in Azure AD) and you will need to get a new one following the previous steps.</p><p>The samples in the collection only cover the most common cases I’ve faced over the last couple of weeks so if you want to include new ones, I’ll be waiting for your <em>Pull Requests</em> in <a href="https://github.com/fedejousset/Dynamics365WebApiPostmanCollection">GitHub</a>.</p><p>On a final note, collections don’t automatically sync when they are updated so if you found this collection useful, you should check periodically the <a href="https://github.com/fedejousset/Dynamics365WebApiPostmanCollection">GitHub repository</a> for new versions and download/import it as explained before.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=abfb259f9eae" width="1" height="1" alt=""><hr><p><a href="https://medium.com/capgemini-microsoft-team/dynamics-365-web-api-postman-collection-abfb259f9eae">Dynamics 365 Web API Postman Collection</a> was originally published in <a href="https://medium.com/capgemini-microsoft-team">Capgemini Microsoft Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Optimistic Concurrency in Dynamics 365 Forms]]></title>
            <link>https://medium.com/capgemini-microsoft-team/optimistic-concurrency-in-dynamics-365-forms-7b4fecc08511?source=rss-2e0507c8681b------2</link>
            <guid isPermaLink="false">https://medium.com/p/7b4fecc08511</guid>
            <category><![CDATA[microsoft]]></category>
            <category><![CDATA[dynamics]]></category>
            <category><![CDATA[dynamics-crm]]></category>
            <category><![CDATA[dynamics-365]]></category>
            <dc:creator><![CDATA[Federico Jousset]]></dc:creator>
            <pubDate>Tue, 12 Jun 2018 10:35:18 GMT</pubDate>
            <atom:updated>2018-06-12T10:35:18.821Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R4glclcqPm8eLWQll7cegw.jpeg" /><figcaption><em>Photo by </em><a href="https://unsplash.com/photos/FkJ3aNGeFMY?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText"><em>Alex Holyoake</em></a><em> on </em><a href="https://unsplash.com/?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText"><em>Unsplash</em></a></figcaption></figure><p>Imagine this scenario: two users access the same Contact record at the same time, they both update the <em>emailaddress1 </em>field with different values (personal email/business email) and finally, they save the changes. As a result of this, the first update will be overridden by the second one and if the Audit setting is not enabled, the data will be gone forever. This is a text-book example of one of the problems of not implementing a concurrency control mechanism, and a possible one in Dynamics 365 with changes happening in parallel by multiple users.</p><h3>Optimistic Concurrency</h3><p>Since CRM 2015 Update 1, it’s possible to use Optimistic Concurrency control to avoid potential data loss. The idea is simple, the entities now have a property called <em>RowVersion </em>(auto incremental number) which stores the retrieved version of the record. When an Update or Delete request is executed (and the <em>ConcurrencyBehavior</em> has been explicitly configured), Dynamics 365 will compare if the record <em>RowVersion </em>is the same than the one stored in the database and rollback the operation if they’re not.</p><p>The <a href="https://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/org-service/reduce-potential-data-loss-using-optimistic-concurrency">MSDN</a> page has good examples to understand how the functionality works. The feature has some limitations and one of those is that it can’t be used in forms using OOB functionality.</p><blockquote><em>Optimistic concurrency behavior can only be set through an SDK call. There is presently no setting for it in a form of the Web application.</em></blockquote><h3>Optimistic Concurrency in forms — Attempt 1</h3><p>Microsoft doesn’t provide a setting to enable this in forms so when I first approached this requirement I thought it was achievable using a plugin. The plan was to create a simple plugin in the Update message (pre-operation) and just set the <em>ConcurrencyBehavior </em>to force the check. Of course, I was wrong. The problem is that the <em>RowVersion </em>property is never passed to the plugin target entity and therefore there’s no way of comparing them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/888/1*invTy-fF9QCyR6xZhDCVzw.png" /></figure><p>It’s possible to read more about this problem in the <a href="https://community.dynamics.com/crm/f/117/t/220118">Community Forum</a>.</p><h3>Optimistic Concurrency in forms — Attempt 2</h3><p>This was a setback, but I was still sure that the approach would work. Dynamics 365 form is retrieving the record, so it must have the <em>RowVersion</em> property stored somewhere, it was just matter of finding where and pass it manually to the plugin (as a workaround for the bug). It took me a while, but I was able to discover a JS function to get it:</p><pre>formContext.data.entity.getRowVersion();</pre><p><em>Disclaimer: I haven’t found any official or unofficial documentation about this function, the MSDN doesn’t mention it so there’s no way for me to know if it’s supported or not.</em></p><p>With this SDK client API, a custom field and a JS function on the OnSave event on the form, I was able to pass the <em>RowVersion </em>to the plugin but again, I run into some issues when trying to set the <em>RowVersion </em>and <em>ConcurrencyBehavior </em>properties in the plugin:</p><pre>request.Target.RowVersion = request.Target.GetAttributeValue&lt;string&gt;(&quot;fjo_rowversion&quot;); <br>request.ConcurrencyBehavior = ConcurrencyBehavior.IfRowVersionMatches;`</pre><p>If these two properties are set on the PreOperation stage, Dynamics is going to completely ignore them and no validation will take place. If we apply the changes during the PreValidation stage, we’ll face a strange error which makes me think that the <em>RowVersion </em>property is being ignored:</p><blockquote><em>Microsoft.Crm.CrmException: The RowVersion property must be provided when the value of ConcurrencyBehavior is IfVersionMatches.</em></blockquote><p>To work around this problem while Microsoft fix it, we can implement our custom check to validate if the <em>RowVersion </em>of the record is different than the one stored in the database and throw an InvalidPluginExecutionException if it’s the case. After doing it, we finally have our optimistic concurrency control in place:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wcbu08ErlF8KK2sw00vLmw.gif" /></figure><p>You can check the complete plugin implementation (Dynamics 365 solutions included) in <a href="https://github.com/fedejousset/OptimisticConcurrency">Github</a>.</p><h3>Conclusions</h3><p>Optimistic Concurrency control is a really good feature but it’s not there for forms. Even though it’s possible to implement it as we saw in this post, it’s still has a couple of drawbacks:</p><ol><li>A field and some client side customizations are required (<a href="https://medium.com/u/385afb3d7026">Max Ewing</a> suggested to use the PreImage <em>RowVersion </em>property but it’s also null) which means that we’ll have to edit every entity where we want to apply the check (getting the version from the Target object would allow us to create a generic solution with no changes at entity level)</li><li>OOB Concurrency control can’t be used in the plugin forcing us to implement a custom one which will also require some performance tests in order to guarantee that this solution is Production ready</li></ol><p>I really hope we’ll have a fix for these problems in a future release and hopefully I’ll be able to write another post about it.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7b4fecc08511" width="1" height="1" alt=""><hr><p><a href="https://medium.com/capgemini-microsoft-team/optimistic-concurrency-in-dynamics-365-forms-7b4fecc08511">Optimistic Concurrency in Dynamics 365 Forms</a> was originally published in <a href="https://medium.com/capgemini-microsoft-team">Capgemini Microsoft Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>