Plugins Development in Dynamics 365 CRM for Beginners | [Blog Series]

If you are looking to start Plugins development in Dynamics 365 CRM Online instance but are a bit digressed in the process, I’ve created this short Crash Course to help you get started with your first plugin on Day 1!

Here are the list of the posts –

  1. Setting up Visual Studio Projecthttps://d365demystified.com/2021/12/31/plugins-development-in-dynamics-365-crm-part-1-setting-up-visual-studio-project/
  2. Registering your pluginhttps://d365demystified.com/2021/12/31/plugins-development-in-dynamics-365-crm-part-2-registering-your-plugin/
  3. Adding Logichttps://d365demystified.com/2021/12/31/plugins-development-in-dynamics-365-crm-part-3-adding-logic/
  4. Debugging the pluginhttps://d365demystified.com/2021/12/31/plugins-development-in-dynamics-365-crm-part-4-debugging-the-plugin/

Further, I’ll enrich this series with posts on best practices and links to useful Tools and code samples by fabulous and brilliant community members! 😊

I hope this is a good enough starting point to you all.

Hope this was helpful! Here are some more Dynamics 365 posts which you might be interested in –

  1. Dynamics 365 Storage Utilization | Dataverse Storage | Power Platform Admin Center
  2. Use Hierarchy in Roll Up Fields in Dynamics 365 CRM
  3. Filter records in a View owned by a Team you are a member of | Dynamics 365 CRM
  4. Get GUID of the current View in Dynamics 365 CRM JS from ribbon button | Ribbon Workbench
  5. Dynamics 365 App For Outlook missing on SiteMap in CRM? Use shortcut link [Quick Tip]
  6. Import lookup referencing records together in Dynamics 365 CRM | [Linking related entity data during Excel Import]
  7. Mailbox Alerts Hide/Show behavior in Dynamics 365 CRM
  8. Excel Importing Notes (Annotation) entity in Dynamics 365 CRM
  9. Enable/Disable the need to Approve Email for Mailboxes in Dynamics 365 CRM CE
  10. Call Azure Function from Dynamics 365 CRM using Webhooks
  11. Show Ribbon button only on record selection in Dynamics CRM
  12. Accessing multiple occurrences of a field in Business Process Flow using JS in D365 CRM

Thank you!!

Advertisement

Plugins Development in Dynamics 365 CRM | Part 4 – Debugging the plugin

Given that you are coming here from the Part 3: Plugins Development in Dynamics 365 CRM | Part 3 – Adding Logic

Let’s see how we can debug the plugin in case of Exceptions / issues!

Profiling

Now, you’ll need to start Debugging in the Plugin Registration tool

  1. In the Plugin Registration Tool, if a Profiler solution was never installed, you will find this button that says Install Profiler.

  2. It’ll begin installing the Profiler and it takes a few minutes until this is completed.


    Once done, you’ll see this message.

  3. One this is done, you’ll see Uninstall Profiler button all the while.
  4. Now, you need to select the Plugin step and then click on Start Profiling.

  5. Once started, the Plugin step will look like this. The step will have “(Profiled)” mentioned.


  6. Now that you have started profiling the plugin step. You’ll need to “perform the operation” in Dynamics 365 CRM. In this case, updating the Group Code field and clicking on Save.

  7. This will not throw the Exception since the method we chose above was Persist to Entity. And the system will just save the record [But of course, the plugin code was not executed since it throws an error]
  8. Next, you can navigate to Plug-in Profiles in Settings

  9. Make sure the Plug-in and custom workflow activity tracking is turned to All in System Settings.


    Else, you’ll see this error on navigating to the Plug-in Profiles section in Settings.


  10. Next, you’ll find the record which was captured when we tried to replicate the scenario to capture the issue.

  11. Now, when you open this record, you’ll need to expand the Serialized Profile section and copy all the content into a Notepad file.

  12. For example, I’m naming my file as error.txt. Remember where you stored this file.


    Now, let’s Debug the plugin!

Debugging

Now, in order to start debugging the plugin, you’ll need to first, stop the Profiling which we started to capture the logs –

  1. Click on Stop Profiling.

  2. Once stopped, click on the Step, then on Debug to open the Dialog box as shown below.


    It’ll open this dialog. Click on the three dots for Profile field.


  3. Select the text file which was saved. It’ll appear if the text file was correctly rendered.
    Then, click on the three dots in Assembly Location. This will accept the .dll file of the plugin

  4. Once you select the DLL, it’ll detect the Plugin and it’ll be show as below.

  5. Don’t click on Start Execution yet!! Go to Visual Studio and open Attach to Process.
    Shortcut for that is Alt + D [pause for a bit], then press [P].
    Find Plugin Registration Tool and then click on Attach.

  6. Once you click on Attach, the VS will be in Debug mode with the Plugin Registration Tool and you can now set the breakpoint at appropriate location in order to capture the debug. Ideally, this should be early on in the plugin to identify the issue step by step.

  7. Now, you can go back to the Plugin Registration Tool and click on Start Execution.

  8. Once it starts, the breakpoint will be hit and you can then take it forward like any C# program debugging using F10, F11, F5 etc.

  9. Let’s assume the exception was hit correctly where we anticipated it to be hit.
    You’ll catch the exception and fix the code.
    [I had purposely commented in earlier posts for this scenario]

  10. Now, I fix the code. Rebuild and Re-deploy the plugin

  11. And as a result, when I perform the operation again, the plugin works and the child records are updated.
    So, I’ll make a change on the Account record.


    And if I check the Contact, the same will have been updated there as well. This indicates that our intended functionality was successfully implemented.


Hope this series was helpful in getting you an understand of how you can write plugins as a newbie. This is just scratching the surface and one of the early ways to write plugins.
I’ll further extend this series in the future to add best practices and some tools in the marketplace to help you write plugins faster and better!

Hope this was helpful! Here are some more Dynamics 365 posts which you might be interested in –

  1. Dynamics 365 Storage Utilization | Dataverse Storage | Power Platform Admin Center
  2. Use Hierarchy in Roll Up Fields in Dynamics 365 CRM
  3. Filter records in a View owned by a Team you are a member of | Dynamics 365 CRM
  4. Get GUID of the current View in Dynamics 365 CRM JS from ribbon button | Ribbon Workbench
  5. Dynamics 365 App For Outlook missing on SiteMap in CRM? Use shortcut link [Quick Tip]
  6. Import lookup referencing records together in Dynamics 365 CRM | [Linking related entity data during Excel Import]
  7. Mailbox Alerts Hide/Show behavior in Dynamics 365 CRM
  8. Excel Importing Notes (Annotation) entity in Dynamics 365 CRM
  9. Enable/Disable the need to Approve Email for Mailboxes in Dynamics 365 CRM CE
  10. Call Azure Function from Dynamics 365 CRM using Webhooks
  11. Show Ribbon button only on record selection in Dynamics CRM
  12. Accessing multiple occurrences of a field in Business Process Flow using JS in D365 CRM

Thank you!!

Plugins Development in Dynamics 365 CRM | Part 3 – Adding Logic

Given that you are coming here from the Part 2: Plugins Development in Dynamics 365 CRM | Part 2 – Registering your plugin

Let’s add logic to catch the Group Code field value and retrieve all the Contacts under the Account to update their Group Code fields!

Context of the Plugin

Since this plugin is registered on one of the common messages like Update, let’s capture the context of the Update record we are working on –

  1. I’ll write a new method to just capture the context. If you are an expert in C#, you could smartly implement this than I have done. 😊
    Here, once the service, context and trace are set, you can have a new method to capture the context.
    In GetRecordContext() method, context.InputParameters[“Target”] will give you what is captured in the current Update context of the specific record you are running this plugin on.
    Typecase it into Entity so that you can retrieve required values from Entity currentEntity .

    Here, I’ve null-checked if the value is a part of the context update (in case the plugin unknowingly set to run on update of all fields), then I’m capturing the field value in a String variable to pass further.
    Once I capture the field value, I’ll pass it to GetAllChilRecords() method
  2. Next, in GetAllChildRecords(groupCode) method, I’m passing the updated string value further so that it can be updated to all retrieved child records.
    Here, I’m using FetchXML query to retrieve the Contacts which have the Company Name field i.e. the Account lookup set to the current record (current Account record on which we are updating the Group Code field)
    Quick Post on FetchXML attributes: Get all attributes in FetchXML in Plugins | Dynamics 365 CRM [Quick Tip]

    Now, there’s a purposeful mistake in the commented code above which we’ll see in the Debugging plugin part of this blog series.

  3. Finally, I’ll Rebuild this code, Update and run the plugin.

Updating the Plugin

Now, let’s say you have updated the code and now you want to re-deploy the plugin code.

  1. Once you have Rebuild. I use Ctrl + Shift + B.

  2. Next, you need to go to the Plugin Registration Tool, select the Plugin Assembly itself and click on Update.

  3. On this screen, even though you see your plugin already selected, click on the three dots to reselect the Assembly and select the .dll file as you originally did while registering it the first time.

  4. And then reselect the assembly and the plugin both and then click on Update Selected Plugins.


  5. Upon correctly updating, the below message is seen and you are done.

  6. Now, let’s run the code and see the “expected” Exception it will throw since we had commented a line on purpose in step #2 in Context of the Plugin section above. 😊

Exceptions

Now, when there are exceptions, you’ll typically see a error pop-up in Dynamics 365 as shown below

And since we can’t tell what it means, we’ll need to debug the plugin to find out the issue.

Let’s move to our Part 4 of the series to see how we can Debug a Plugin: Plugins Development in Dynamics 365 CRM | Part 4 – Debugging the plugin

Hope this was helpful! Here are some more Dynamics 365 posts which you might be interested in –

  1. Dynamics 365 Storage Utilization | Dataverse Storage | Power Platform Admin Center
  2. Use Hierarchy in Roll Up Fields in Dynamics 365 CRM
  3. Filter records in a View owned by a Team you are a member of | Dynamics 365 CRM
  4. Get GUID of the current View in Dynamics 365 CRM JS from ribbon button | Ribbon Workbench
  5. Dynamics 365 App For Outlook missing on SiteMap in CRM? Use shortcut link [Quick Tip]
  6. Import lookup referencing records together in Dynamics 365 CRM | [Linking related entity data during Excel Import]
  7. Mailbox Alerts Hide/Show behavior in Dynamics 365 CRM
  8. Excel Importing Notes (Annotation) entity in Dynamics 365 CRM
  9. Enable/Disable the need to Approve Email for Mailboxes in Dynamics 365 CRM CE
  10. Call Azure Function from Dynamics 365 CRM using Webhooks
  11. Show Ribbon button only on record selection in Dynamics CRM
  12. Accessing multiple occurrences of a field in Business Process Flow using JS in D365 CRM

Thank you!!

Plugins Development in Dynamics 365 CRM | Part 2 – Registering your plugin

Given that you are coming here from the Part 1: https://d365demystified.com/2021/12/31/plugins-development-in-dynamics-365-crm-part-1-setting-up-visual-studio-project/

Let’s register our plugin to the Dynamics 365 CRM organization using the Plugin Registration Tool!

Log into Plugin Registration Tool

Based on where you have downloaded the Plugin Registration Tool, navigate to the folder and follow the below –

  1. Open the Plugin Registration Tool from the directory.

  2. Now, given that this is Dynamics 365 CRM Online (Customer Engagement / Dataverse) environment, you’ll make sure Office 365 is selected and then you’ll need to enter Admin Credentials.

  3. Once successfully authenticated, you’ll be asked to choose which organization this is in. Given that development should ideally be done on a Dev/Sandbox environment, you’ll select the appropriate environment here.

  4. Once logged in, you’ll see the the assemblies registered with the CRM environment. These are the out-of-the-box assemblies which are not supposed to be manipulated.

Register your Assembly

Let’s register the Plugin Assembly –

  1. Click on the Register New Assembly button and click on New Assembly

  2. You can now click on the three dots in order to navigate to the .DLL file which was generated when you Build the project.

  3. You’ll then need to navigate to the bin folder (Either Debug or Release)

  4. Once you select the .dll file, you’ll see the plugins which are exposed in the dll i.e. the Plugins of .CS of ‘public’ visibility.
    Once this looks good, click on the Register Selected Plugins

  5. Upon successful registration, you’ll see the below message.

  6. And your Assembly will now be registered successfully using the Plugin Registration Tool.


  7. In case this Project was not signed with .snk file, you’d see the below message.
    Assemblies containing Plugins must be strongly signed. Sign the Assembly using a KeyFile


    Now, the assembly has been registered. Next, we’ll add a step (you can call it a trigger for the plugin to start executing)

Register Step for Plugin

Now, let’s register a step for the Plugin –

  1. Now, given that the Assembly was successfully Registered, the next step is to Register a Plugin Step.
    Expand the Assembly, then expand the Plugin itself to which you want to add a Step.

  2. As per the scenarios from Blog 1, the plugin is supposed to be triggered on change of the Account’s field Group Code.
    So, when you click on Register New Step, you’ll get to configure the Step
    Here, Message means the “operation” on occurrence of which the Plugin should be triggered. In this example, we want to trigger the plugin on an Update operation.
    Primary Entity denotes which entity is this targeted at. Account in this example.
    Then, the Filtering Attributes is available if the Message is set to Update since Filtering Attribute let’s you select which all fields should be listened to in order to run/trigger the plugin.


  3. Clicking on the three dots, you’ll get to choose the fields. In this example, we’ll select the Group Code field.

  4. Once you click OK after choosing what all fields the plugin should fire on, you should select “under whose security context should the plugin be running”
    Run in User’s Context is that field to choose the user.
    In my practice, I choose either Calling User or a System Administrator

  5. Finally, I’ll choose “when in the context of the operation” should the plugin be triggered.
    Since, I want the plugin to run “after” the “Update” operation is performed, I’ll select PostOperation.
    And Execution Mode has options – Asynchronous / Synchronous defines if the plugin will run in the background or with the operation itself.

  6. Once I choose these preferences, I’ll click on Register New Step and the Step will be registered on the Plugin.

  7. At this point, you’ve successfully registered the plugin assembly and a step on the plugin to be triggered on the update of the Account field – ‘Group Code’.

But we haven’t written any logic in place, right? So Part 3 we’ll write a short logic to add meaning to this tutorial

Link to Blog 3: https://d365demystified.com/2021/12/31/plugins-development-in-dynamics-365-crm-part-3-adding-logic/

Hope this was helpful! Here are some more Dynamics 365 posts which you might be interested in –

  1. Dynamics 365 Storage Utilization | Dataverse Storage | Power Platform Admin Center
  2. Use Hierarchy in Roll Up Fields in Dynamics 365 CRM
  3. Filter records in a View owned by a Team you are a member of | Dynamics 365 CRM
  4. Get GUID of the current View in Dynamics 365 CRM JS from ribbon button | Ribbon Workbench
  5. Dynamics 365 App For Outlook missing on SiteMap in CRM? Use shortcut link [Quick Tip]
  6. Import lookup referencing records together in Dynamics 365 CRM | [Linking related entity data during Excel Import]
  7. Mailbox Alerts Hide/Show behavior in Dynamics 365 CRM
  8. Excel Importing Notes (Annotation) entity in Dynamics 365 CRM
  9. Enable/Disable the need to Approve Email for Mailboxes in Dynamics 365 CRM CE
  10. Call Azure Function from Dynamics 365 CRM using Webhooks
  11. Show Ribbon button only on record selection in Dynamics CRM
  12. Accessing multiple occurrences of a field in Business Process Flow using JS in D365 CRM

Thank you!!

Plugins Development in Dynamics 365 CRM | Part 1 – Setting up Visual Studio Project

If you are a newbie to Dynamics 365 CRM and need to connect dots in getting your first plugin up and running, this post is for you! I’ve tried to summarized this in the shortest possible way. 😊 Hope this gets you going quickly!

Since you’re here, it’s presumed that you are told to learn or implement a Dynamics 365 CRM plugin with some business logic in mind based on the requirements. So, here’s how you get started in your learning journey!

Pre-Requisites

Here’s what you need to be have installed in order to proceed to writing a plugin –

  1. Plugin Registration Tool – Required for your to connect to the Dynamics 365 environment and deploy your plugin on.
    How to get Plugin Registration Tool: Download Plugin Registration Tool for Dynamics 365 CRM using PowerShell
  2. Microsoft Visual Studio – You’ll need to write your plugin in a Visual Studio IDE as it’s the preferred way to code your plugin and also to Version Control / Source Control.

Scenario

Now, before you decide why you have to write a plugin, it is presumed that you have some high-level understanding as to why you are writing this plugin.

To keep it short, here are some points –

  1. Understand Plugin Execution Pipeline (Basically, it means when is the plugin supposed to run when you perform a certain operation) – https://carldesouza.com/dynamics-365-plugin-execution-pipeline/

Example Business Scenario

Here’s a quick example we’ll consider which we will implement using a plugin –

  1. An account has a custom field called as Group Code.

  2. So whatever is updated in this field should be updated on all the Child Contact records under the Account.


    Now, let’s write a quick plugin to implement this.

Writing a Plugin – Visual Studio

Given that you want to start writing a plugin, you must also have understood some concepts –

  1. You’ll need to create a new .NET Framework Project in order to get started. I use Visual Studio 2022 (This was newly released at the time of writing this post)
    So the type of Project required is a Class Library of .NET Framework

  2. Once you click Next, provide a relevant name to the Project. As a D365 Consultant working on multiple projects, you should be able to identify the library/assembly by the name as to which Org and what Module it belongs to.
    In my case, I’m calling it CFT158SalesPlugins which is sufficient to give an idea of what org and what module this assembly is for.

  3. Once I click on Create, an Empty Project with the standard Class1 will be created which will be ready for you to start writing.

  4. Next, since Dynamics 365 CRM plugins extend IPlugin interface provided by Microsoft Dynamics, you’ll need to fetch references for the same.



    Now, right-click on the Project itself and click on Manage NuGet Packages…

  5. Then, go to Browse and then search for Dataverse…

  6. You’ll find Microsoft.CrmSdk.CoreAssemblies which you can download. I usually choose a little older version than the current one.

  7. Make sure you have selected the correct one. Then, click OK.


    Next, you get a chance to also look at the licensing terms before you Accept. Once you are OK, you can click on I Accept.

  8. If you have the Output window open in your Visual Studio, you’ll be able to see the progress. It only takes a few seconds for the references to be imported.

  9. Once done, you can see that the references required have now been added to the project.

  10. I’ll rename my Class1.cs to something that gives an idea of what the Plugin would do.
    So, for example, I’m setting it to AccountUpdate.
    Detailed post on Renaming or Deleting a Plugin in Dynamics 365 CRM
    Now, that my class is renamed, I’ll also add the references to the Class File so that I can use the IPlugin interface. In most common Plugin scenarios, you’ll need Microsoft.Xrm.Sdk amongst other references too.
    My personal practice is to include as shown below –


Setting Initial Methods

Now, let’s set a template of which we can start to code the plugin. Before we do that, some common Methods need to be added first.

  1. I’ll now extend the IPlugin interface to the class.

  2. As you choose the IPlugin, in Visual Studio, you’ll be prompted for some actions which will auto-complete the interface process. Look for the icon on the left hand side and expand the menu to find Implement Interface


    Once done, the Execute method will be populated as below. Execute method is the first method from where the plugin execution starts.
    Also, make sure the class is public so that we can register is successfully in the Plugin Registration Tool.

  3. Now, below are some helper methods which are required for the plugin to be registered on the environment.
    You can copy from here:

    context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
    service = ((IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory))).CreateOrganizationService(context.UserId);
    trace = (ITracingService)serviceProvider.GetService(typeof(ITracingService));




  4. In order to understand what these methods are, you can simply hover over these and read the definition. If you don’t understand these right away, it’s not a problem. But, it’s recommended that you thoroughly understand the purpose behind each of these.

  5. Then, this should be the first method to call in order to establish connection with the Dynamics 365 CRM organization you are hosting this plugin on.

  6. Next, you’ll need to Sign the Assembly before it could be registered on the environment using Plugin Registration Tool.
    Right-click on the Project and then choose Properties.

  7. Once in Properties, look for the Signing section on the left-hand side on the menu.
    Notice that the Sign the assembly is not yet enabled.

  8. Once you tick it, it’ll expose the area below and you’ll be able to create a new strong key name file.

  9. When I click on new, I created a strong name key file –
    Note: I’ve not password protected the Strong Name Key I’m creating but it’s up to you to maintain it if needed.

  10. Once I click OK, the .snk file will appear here.

  11. Finally, build the Project at this stage and we’ll move towards Registering this Plugin.

    Now, at this point, we have established the code which is ready to be hosted on the Dynamics 365 CRM organization itself. Post this point, you’ll now code the logic which is supposed to be done by the plugin.

But first, let’s move to part 2 where you’ll first host this assembly in the Dynamics 365 CRM environment!

Registering Plugin in Dynamics 365 CRM environment

Here’s the Part 2 of the Blog: https://d365demystified.com/2021/12/31/plugins-development-in-dynamics-365-crm-part-2-registering-your-plugin/

Hope this was helpful! Here are some more Dynamics 365 posts which you might be interested in –

  1. Dynamics 365 Storage Utilization | Dataverse Storage | Power Platform Admin Center
  2. Use Hierarchy in Roll Up Fields in Dynamics 365 CRM
  3. Filter records in a View owned by a Team you are a member of | Dynamics 365 CRM
  4. Get GUID of the current View in Dynamics 365 CRM JS from ribbon button | Ribbon Workbench
  5. Dynamics 365 App For Outlook missing on SiteMap in CRM? Use shortcut link [Quick Tip]
  6. Import lookup referencing records together in Dynamics 365 CRM | [Linking related entity data during Excel Import]
  7. Mailbox Alerts Hide/Show behavior in Dynamics 365 CRM
  8. Excel Importing Notes (Annotation) entity in Dynamics 365 CRM
  9. Enable/Disable the need to Approve Email for Mailboxes in Dynamics 365 CRM CE
  10. Call Azure Function from Dynamics 365 CRM using Webhooks
  11. Show Ribbon button only on record selection in Dynamics CRM
  12. Accessing multiple occurrences of a field in Business Process Flow using JS in D365 CRM

Thank you!!

Get all attributes in FetchXML in Plugins | Dynamics 365 CRM [Quick Tip]

In Plugin development, when you use FetchXML while using RetrieveMultiple to retrieve data.

In some scenarios since you want to retrieve a large number of columns, so mentioning each column is cumbersome on not worth to save the extra processing. In that case, it’s better to retrieve everything.

Here’s a quick tip on how you can quickly retrieve everything in 1 tag in the FetchXML!


Creating FetchXML using Advanced Find

As a standard practice, just to revise – this is how you create FetchXML from Advanced Find.

  1. While working on Advanced Find, you click on Download Fetch XML

  2. This gives you an XML output of the FetchXML query which you can use in your plugins.

All Attributes

Here’s what you change in order to get all attributes –

  1. You remove all the marked columns as shown below

  2. And replace the <attribute> tags with <all-attributes />. Make sure no other <attribute name /> tags are included in combination with this <all-attributes /> tag.

Hope this was helpful! Here are some more Dynamics 365 posts which you might be interested in –

  1. Dynamics 365 Storage Utilization | Dataverse Storage | Power Platform Admin Center
  2. Use Hierarchy in Roll Up Fields in Dynamics 365 CRM
  3. Filter records in a View owned by a Team you are a member of | Dynamics 365 CRM
  4. Get GUID of the current View in Dynamics 365 CRM JS from ribbon button | Ribbon Workbench
  5. Dynamics 365 App For Outlook missing on SiteMap in CRM? Use shortcut link [Quick Tip]
  6. Import lookup referencing records together in Dynamics 365 CRM | [Linking related entity data during Excel Import]
  7. Mailbox Alerts Hide/Show behavior in Dynamics 365 CRM
  8. Excel Importing Notes (Annotation) entity in Dynamics 365 CRM
  9. Enable/Disable the need to Approve Email for Mailboxes in Dynamics 365 CRM CE
  10. Call Azure Function from Dynamics 365 CRM using Webhooks
  11. Show Ribbon button only on record selection in Dynamics CRM
  12. Accessing multiple occurrences of a field in Business Process Flow using JS in D365 CRM

Thank you!!

Create a Flyout menu for ribbons in Ribbon Workbench | XrmToolBox

Here’s how you can create Flyout menu in Ribbon Workbench.
Also, for most ribbon customization, you can edit using the Command Editor in Power Apps but this is in Preview at the time of writing this post –

  1. How to add low-code Power Fx buttons to model-driven apps (Commanding v2) – https://www.develop1.net/public/post/2021/07/25/commandingv2
  2. Comparison between Ribbon Workbench and Power Fx Command Buttons –
    https://www.develop1.net/public/post/2021/07/25/RibbonWorkbench-vs-PowerFx

Meanwhile, here’s how you can create a Flyout menu in Dynamics 365 CRM Ribbon using Ribbon Workbench in the XrmToolBox

Ribbon Workbench in XrmToolBox

In classic XrmToolBox style, here’s how you create a Flyout button. Given that you are aware of how to load the Entity’s ribbon in a solution and then onto the Ribbon Workbench, we’ll see at how we can create a button on Account Form –

  1. Insert the Flyout menu in the Ribbon where you want to insert this. In this case, in the Form ribbon of the Account entity.

  2. Once dragged, pick a Menu Section control and insert into the flyout canvas shown in screenshot below. Because all the Buttons will fall under that Buttons can’t be added directly into the Flyout menu.

  3. Now, you can name the Menu Section itself as show below –
    Note: In case if you named the Section correctly and it didn’t appear the first time, clicking on some other component and then clicking it back will show it correctly.

  4. Now, you can insert buttons underneath the section. In this case, I’ll add 2 buttons for Pause and Cancel.


  5. Make sure you populate the Command and the ModernImage icon for it’s icon so that the buttons are visible when you publish. Without a Command being attached to the Button, the button will not be visible.
    The final button layout will look like this.
    Note: In case if you named the Section correctly and it didn’t appear the first time, clicking on some other component and then clicking it back will show it correctly.

  6. Once ready, publish the changes and see. Your Flyout menu will be ready and will look like this!

Hope this was useful!

Here are some more XrmToolBox related posts which you might want to check –

  1. Show custom ribbon button based on Security Role of the logged in User in Dynamics 365 | Ribbon Workbench in XrmToolbox
  2. Connecting XrmToolBox to an MFA enabled Dynamics 365 environment | Azure AD
  3. Find deprecated JS code used in your Dynamics 365 environment | Dynamics 365 v9 JS Validator tool | XrmToolBox
  4. Delete App Passwords created by other users in Office 365 | Multi-factor authentication
  5. Single record and multiple record auditing in Dynamics 365 to Audit record access | M365 Compliance
  6. Filter records in a View owned by a Team you are a member of | Dynamics 365 CRM
  7. Show custom ribbon button based on Security Role of the logged in User in Dynamics 365 | Ribbon Workbench in XrmToolbox
  8. Ribbon button visibility based on a field value in Dynamics 365 | Ribbon Workbench
  9. Get GUID of the current View in Dynamics 365 CRM JS from ribbon button | Ribbon Workbench
  10. Pass Execution Context to JS Script function as a parameter from a Ribbon button in Dynamics 365 | Ribbon Workbench

Thank you!

Renaming or Deleting a Plugin in Dynamics 365 CRM

At times, if you realize you need to rename your plugin but get error while updating it in the Plugin Registration Tool, then this post might help you out!

Let’s see how we correctly rename the plugin in question and update it. Most times, if you encounter this error, make sure you follow the post to be able to successfully perform this operation.

Scenario

At times, there are scenarios where you need to rename a Plugin just because the naming convention has not been followed in the Plugin Assembly because multiple developers were contributing or just because you came up with a better name altogether –

  1. Let’s assume this is the name given originally in a plugin

  2. And you want to rename it to, say “AccountValidation
    So, you typically would rename the class file in the Plugin Assembly (Class Library)


  3. And it’ll ask you for the confirmation to update the name of the class as well.

  4. And once you confirm, the class will be renamed as well.

  5. Now, when you try to Build the solution & update the assembly again, it’ll show you your renamed plugin which you are trying to update.

  6. But, when you try to Update the Selected Plugin, it’ll give you the below error.
    [The previous Plugin name] not found in PluginAssembly [PluginAssembly details] which has a total of [x] plugin/workflow activity types.


    Let’s see how to overcome this.

Workaround

So, here’s how you successfully update the plugin assembly with the renamed plugin.

  1. Unregister the Plugin only which was renamed.
    Please make sure you note all the Steps and Images with that plugin since you’ll need to manually add them back again once the new renamed plugin is registered. It’s a new registration and not updating the existing plugin which was previously registered.

  2. Now when you unregister, re-update the Assembly in which the renamed plugin will be registered as a new plugin. Post which, you’ll need to add the necessary steps/images to it.

Deleting a Plugin

The approach to deleting a Plugin from the Assembly is also no different –

  1. Let’s say you have another plugin called as “ContactUpdate“, and you want to delete it to declutter your assembly from plugins which you don’t need at all.
    You select the Class file in Visual Studio and Delete it.

  2. It’ll prompt you that you are permanently deleting the file and it can’t be reverted.

  3. Once this is deleted, and you build the solution again and Update the Assembly, you’ll find that the plugin you deleted will be missing for an update. And that’s when you’ll see another error as the Assembly update in the Plugin Registration Tool will try to update the plugin you just deleted.

  4. Just like how we Unregistered in the rename process above, you’ll need to Unregister the plugin first in order to Update the rest of the plugins successfully in the Assembly.

  5. And finally, you’ll be able to update the assembly for the rest of the Plugins in the assembly post deleting the plugin.

Also, another way is to also follow the below –

  1. Create a new plugin with the name you wish to set.
  2. Copy the code over the new plugin and register it in the Plugin Registration Tool.
  3. Once done, replicate the Steps/Images on the new plugin in the Plugin Registration Tool.
  4. Now, you can also safely delete the old plugin which has the old name.
  5. Delete from the Code and then from the Registration Tool and then update so that the library too is updated with the deleted one as well!

Hope this was helpful! Here are some more Dynamics 365 posts which you might be interested in –

  1. Dynamics 365 Storage Utilization | Dataverse Storage | Power Platform Admin Center
  2. Use Hierarchy in Roll Up Fields in Dynamics 365 CRM
  3. Filter records in a View owned by a Team you are a member of | Dynamics 365 CRM
  4. Get GUID of the current View in Dynamics 365 CRM JS from ribbon button | Ribbon Workbench
  5. Dynamics 365 App For Outlook missing on SiteMap in CRM? Use shortcut link [Quick Tip]
  6. Import lookup referencing records together in Dynamics 365 CRM | [Linking related entity data during Excel Import]
  7. Mailbox Alerts Hide/Show behavior in Dynamics 365 CRM
  8. Excel Importing Notes (Annotation) entity in Dynamics 365 CRM
  9. Enable/Disable the need to Approve Email for Mailboxes in Dynamics 365 CRM CE
  10. Call Azure Function from Dynamics 365 CRM using Webhooks
  11. Show Ribbon button only on record selection in Dynamics CRM
  12. Accessing multiple occurrences of a field in Business Process Flow using JS in D365 CRM

Thank you!!

Update Flow Schema [The power flow’s logic app flow template was invalid] error | Power Automate Tip

Error on trigger of the Flow which reads as “The power flow’s logic app flow template was invalid”

This could be because the schema of the Flow is not longer valid and needs to be refreshed. Here’s a simple way on how you can do this.

Scenario

Let’s consider this Scenario where you have an On-Demand Flow in Dynamics 365 CRM which is using a Dataverse (Legacy) trigger –

  1. You see the Flow as below in Dynamics 365 CRM on the record which you can call (Replacement of your classic On-Demand Workflows in CRM 😊)
    Flow didn’t run as expected and hence, the next step was to investigate.

  2. So, to further investigate, you open the Flow and find this error notification already in the Edit mode itself.

    The complete error message reads as –
    The power flow’s logic app flow template was invalid. The ‘type’ property of template trigger ‘manual’ at line ‘1’ and column ‘11024’ has the value ‘Manual’ which is deprecated in schema version ‘2016-04-01-preview’ and onwards.

  3. This means the Schema has been deprecated and you’ll need to refresh the same.

Fix

Here’s how you can quickly fix this –

  1. Remove the trigger


  2. And then re-add the same trigger. In this case, Dataverse (Legacy)


  3. Note that the references will be removed since you removed this step/trigger.


    Now, for this particular Flow Trigger, I further faced issues while receiving the Body correctly. And got something like this –

    I’ll further investigate this and update this post

    Now, save the Flow and re-attempt Running it.
    Note: Since the schema has been updated, you’ll need to investigate the check the rest of the Flow for any changes you might need to make.
  4. For Logic Apps, Microsoft Docs has provided this directive – https://docs.microsoft.com/en-us/azure/logic-apps/logic-apps-schema-2016-04-01#upgrade-your-schema?WT.mc_id=DX-MVP-5003911

Hope this helps!

Here are some Power Automate posts you want to check out –

  1. Call Flow from Webhooks in Dynamics 365 CRM | Power Automate
  2. Call a Flow from Canvas Power App and get back response | Power Platform
  3. Showing Sandbox or Non Production Apps in Power App mobile app
  4. Create a Power Apps Per User Plan Trial | Dataverse environment
  5. Install On-Premise Gateway from Power Automate or Power Apps | Power Platform
  6. Co-presence in Power Automate | Multiple users working on a Flow
  7. Search Rows (preview) Action in Dataverse connector in a Flow | Power Automate
  8. Suppress Workflow Header Information while sending back HTTP Response in a Flow | Power Automate
  9. Call a Flow from Canvas Power App and get back response | Power Platform\
  10. FetchXML Aggregation in a Flow using CDS (Current Environment) connector | Power Automate
  11. Parsing Outputs of a List Rows action using Parse JSON in a Flow | Common Data Service (CE) connector
  12. Asynchronous HTTP Response from a Flow | Power Automate
  13. Validate JSON Schema for HTTP Request trigger in a Flow and send Response | Power Automate
  14. Converting JSON to XML and XML to JSON in a Flow | Power Automate

Thank you!

Upload documents more than 50MB to SharePoint in Dynamics 365 | Quick Tip

Currently, Dynamics 365 SharePoint Integration document limit is 50MB.

And if you try to upload a Document greater than 50MB, it’ll give you the below error –

So here’s what they mean by directly uploading to SharePoint, in case you are new to Dynamics and don’t know if you can access SharePoint directly from Dynamics.

Quick Tip

Here’s how you can upload larger files greater than 50MB –

  1. In the Documents tab, you’ll see the

  2. This will take you to the SharePoint location in the new tab which this Document folder points to –

  3. And you can choose to upload your file –

  4. And your file will be uploaded even if it’s larger than 50MB

  5. And the same will be reflected in Dynamics’ Document grid on the record as well.

Hope this was helpful! Here are some more Dynamics 365 posts which you might be interested in –

  1. Enable SharePoint Online integration Dynamics 365 | Power Platform Admin Center
  2. Dynamics 365 Storage Utilization | Dataverse Storage | Power Platform Admin Center
  3. Use Hierarchy in Roll Up Fields in Dynamics 365 CRM
  4. Filter records in a View owned by a Team you are a member of | Dynamics 365 CRM
  5. Get GUID of the current View in Dynamics 365 CRM JS from ribbon button | Ribbon Workbench
  6. Dynamics 365 App For Outlook missing on SiteMap in CRM? Use shortcut link [Quick Tip]
  7. Import lookup referencing records together in Dynamics 365 CRM | [Linking related entity data during Excel Import]
  8. Excel Importing Notes (Annotation) entity in Dynamics 365 CRM
  9. Enable/Disable the need to Approve Email for Mailboxes in Dynamics 365 CRM CE
  10. Call Azure Function from Dynamics 365 CRM using Webhooks
  11. Show Ribbon button only on record selection in Dynamics CRM
  12. Accessing multiple occurrences of a field in Business Process Flow using JS in D365 CRM

Thank you!!