Tip #1137: Learn language and study API to simplify your code

Simple life

I already wrote about the benefits of learning new language features. Equally important is to understand what assemblies are available as part of Dynamics 365 SDK, how they work, what classes and interfaces are available, and how the edge cases work (basically, “what-if” scenarios, like “what if this is null”). This week I had “privilege” […]

Tip #1135: For plugins, use SDK with the same or below the server version

Mismatch

Problem Another week, another challenge from Guido “Future Olive Farmer” Preite: I created a plugin for one Online instance (version 8.2.2.1862),  I created a class library project with .NET 4.5.2 and with nuget I installed the Microsoft.CrmSdk.CoreAssemblies version 9.0.2.3 I registered the plugin and I always get this error: Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=8.0.0.0, Culture=neutral, […]

Tip #1130: Refactoring Makes Sense For Configuration Too

If you hang around developers long enough you will hear them use the term “refactoring”. On one project, the developer even had a “Refactor Friday” where this is all they did at the end of the week. So what is refactoring and why should us configuration folks care? Refactoring is taking existing code and reworking […]

Tip #1127: Don’t update auto number field

Locked boxes with the engraved numbers

We did mentioned in the past that most of the good inventions are driven by the laziness. Auto numbering the new records is one of those. Instead of manually looking up the next available number, calling other users to see if they have any intention of creating a new record in the next few minutes, […]

Tip #1122: Multiple tokens in cache

Golf balls in a bucket

If you are working with multiple user or app identities (e.g. for testing), and the code uses ADAL, and especially if the application is killed or crashes, you may occasionally get an error: multiple_matching_tokens_detected: The cache contains multiple tokens satisfying the requirements. Call AcquireToken again providing more requirements (e.g. UserId) Note that it does not […]

Tip #1112: Impersonate Azure AD users

Elvis impersonator

Developers are familiar with the concept of impersonating Dynamics 365 users. It’s easy – all you need to do is to add MSCRMCallerID header to your Web API request, and you’re done (assuming that you have prvActOnBehalfOfAnotherUser privilege). One of the typical scenarios where you’d want to use the impersonation when you have a web […]

Tip #1077: Connect to the right instance

Connect

As Guido “Future Olive Farmer” Preite has discovered, sometimes CrmServiceClient may connect to the wrong instance. Just like that. Dynamics 365 instances now can be backed up and restored at will. The side-effect of this awesomeness is that URLs and unique names may no longer match, leading to the fun times with connections. Here’s the […]

Tip #1066: Discover Azure AD tenant ID with Occam’s razor

Occam's razor

As developers, from time to time we are puzzled by simple questions: How to discover Azure AD tenant ID based on Dynamics 365 organization URL? Under the normal circumstances I would have put my condescending hat on (did I forget to take it off, again?) and say something like “Use AuthenticationParameters.CreateFromResourceUrlAsync method from ADAL, of […]