Dynamics 365 – Understanding Plugin Depth

In Dynamics 365, plugins have the concept of “depth”. This is how many times the plugin is firing based on certain events. The depth is part of the plugin context. Let’s go through an example of how plugin depth works. Create a new class library in Visual Studio: Add some code to check the depth: Let’s runs this every time Accounts are retrieved. On invoking our plugin by selecting a … Continue reading Dynamics 365 – Understanding Plugin Depth

Adding an OnChange Script Programmatically in Dynamics 365 Power Apps

In this post, we will look at how to programmatically add an OnChange script in Dynamics 365 Power Apps, so when a user tabs off a field, the script is run. First, when we tab off a field, such as this fax field on the account record, we would like our script to run: Without doing this programmatically, we would select the field and select Change Properties: Then go to … Continue reading Adding an OnChange Script Programmatically in Dynamics 365 Power Apps

Update a Record using Xrm.WebApi

Let’s look at how we can use the Xrm.WebApi to update a record. Let’s use the Account entity, where we have a field called My New Field (new_mynewfield): Here’s the update script: We can run this in the browser console or in a web resource. We see we get a Success callback: In advanced find, we see the field has been updated: Interestingly, if we were to run this with … Continue reading Update a Record using Xrm.WebApi

Get the Id of a Record on a Page in Dynamics 365 Power Apps

Let’s look at how to get the Id of a record in Dynamics 365 Power Apps using JavaScript. We can see below our Account record with the Id in the URL: To get the Id of the record in JavaScript, let’s run the code below, which Xrm.Page.data.entity.getId(); or by passing the formContext: formContext.data.entity.getId(); And to remove the curly braces: Xrm.Page.data.entity.getId().replace(“{“, “”).replace(“}”, “”); Or formContext.data.entity.getId().replace(“{“, “”).replace(“}”, “”);  

Increasing Email Attachment Size in Dynamics 365

In Dynamics 365, the maximum size of an email attachment defaults to 5120kB, or 5MB. Let’s look at how we can increase this. First, let’s create an email message and try to add a large attachment. Go to Activties and create a new Email: Add a new attachment: Click Choose File: Let’s add a PDF file: When we try to attach it, we get the message that “The attachment is … Continue reading Increasing Email Attachment Size in Dynamics 365

Coding Multiple Plugins in One Assembly in Dynamics 365

In this post we will look at how to code 2 plugins in one assembly. This might be useful if you want to keep related pieces of code under the same code base. Let’s create a new VS project: Rename the class to Plugins: Add Microsoft.CrmSdk.CoreAssemblies through NuGet. Add the code. We will add 2 functions, Plugin1 and Plugin2: The code will write a Plugin Trace Log entry.   Sign … Continue reading Coding Multiple Plugins in One Assembly in Dynamics 365

XrmToolBox Error When Loading

When opening the XrmToolBox, you may come across errors such as: System.TypeLoadException: Could not load type XrmToolBox.Extensibility.Interaces.INoConnectionRequired System.IO.FileNotFoundException: Could not load file or assembly ‘WeifenLuo.WinFormsUI.Docking, Version=3.0.4.0, Culture=neutral, PublicKeyToken=5cded1a1a0a7b481’ or one of its dependencies. The system cannot find the file specified. The problem here is to do with one of the plugins that is in your XrmToolBox environment. To resolve this, go to: %appdata%\MscrmTools\XrmToolBox\Plugins\ Copy the files from the Plugins folder to … Continue reading XrmToolBox Error When Loading

Calling a Dynamics 365 Workflow through JavaScript

In Dynamics 365, you may want to call a workflow directly from JavaScript. This can be achieved using the WebAPI. Let’s say we have a workflow as follows, that creates a task on the account: For the sake of the demo, we will hardcode the Workflow Id and Account Id. Copy the Workflow Id from the URL: Now create an account: Get the Id of the account: Now the code. … Continue reading Calling a Dynamics 365 Workflow through JavaScript