Smart Buttons in Ribbon Workbench | XrmToolBox

You must’ve definitely used Scott Durow’s Ribbon Workbench in XrmToolBox which is one of the most popular tools for in the XrmToolBox. Here’s what Smart Buttons can do to further extend capabilities of the Ribbon!



Let’s see how you can install Smart Buttons if you already have not installed the solution in your environment and also I’ll summarize how each of these will work! Hope this post captures the bare-minimum well.

Installing Smart Buttons

Here’s how you can install the Smart Buttons solution to make it appear in your Ribbon Workbench!
Link: Install Smart Buttons for Ribbon Workbench | XrmToolBox

Smart Button Posts

  1. Run Reporthttps://d365demystified.com/2023/01/17/run-report-using-smart-button-in-ribbon-workbench-xrmtoolbox/
  2. Run Workflow https://d365demystified.com/2023/01/17/run-workflow-smart-button-in-ribbon-workbench-xrmtoolbox/
  3. Run Webhookhttps://d365demystified.com/2023/01/17/run-webhook-smart-button-in-ribbon-workbench-xrmtoolbox/
  4. Quick JS https://d365demystified.com/2023/01/17/run-js-snippet-using-smart-button-in-ribbon-workbench-xrmtoolbox/
  5. Open Dialoghttps://d365demystified.com/2023/01/17/open-dialog-using-smart-button-in-ribbon-workbench-xrmtoolbox/

Hope this helps!

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

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

Thank you!

Advertisement

Open Dialog using Smart Button in Ribbon Workbench | XrmToolBox

Here’s how you can use Dialog from Smart Buttons in Ribbon Workbench. In case you haven’t yet installed Smart Buttons in your Ribbon Workbench for your organization – Here’s a post for that – Install Smart Buttons for Ribbon Workbench | XrmToolBox

Now that it’s given you might have installed Smart Buttons already, let’s review how you can use the Run Report button for your Organization

Scenario

Run Dialog button

Here’s how you can open a Canvas App as a Dialog in a Model-Driven App –

  1. In Ribbon Workbench, you can see the Open Dialog option in the Smart Buttons menu in Ribbon Workbench.

  2. Upon Dragging it to the ribbon (I’m using the Form ribbon in this example), you’ll be asked the below in a Dialog box.
    Title should have the title which the button should show on the ribbon.
    Dialog URL or Custom Page Unique Name should have the URL or the name of the Custom Page you have in your Model-driven App (I’ll share links below on how to get both from the official source itself)
    Width and Height as suggests should be specified in pixel dimensions.
    Dialog Title should show how the Dialog Box should look like.

  3. Here’s how the Custom Page’s name is (make sure the Custom Page is also added to the Model-Driven App your ribbon is in)

  4. Below are the links for both – Canvas App and Custom Page which can be added in the Dialog.

    Links:
    Custom Page to be added to the Open Dialog button – https://www.develop1.net/public/post/2021/08/08/custom-page-dialog-smart-button
    Canvas App to be added to the Open Dialog button – https://www.develop1.net/public/post/2020/09/30/new-smart-button-custom-dialogs-in-model-driven-apps-using-canvas-apps
  5. Once this is done, it’ll appear on the ribbon and once you confirm, you can commit the changes by Publishing the customization.

  6. Once this is done, publish and let’s see how the customization will look.

Working

Now that the customization are published, you can see as below –

  1. Here’s the button on the Form ribbon I added to.

  2. When you click it, the dialog box will appear as below –

Hope this helps!

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

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

Thank you!

Run JS snippet using Smart Button in Ribbon Workbench | XrmToolBox

Here’s how you can call a piece of JavaScript code snippet from Smart Buttons in Ribbon Workbench. In case you haven’t yet installed Smart Buttons in your Ribbon Workbench for your organization – Here’s a post for that – Install Smart Buttons for Ribbon Workbench | XrmToolBox

Now that it’s given you might have installed Smart Buttons already, let’s review how you can use the Run Report button for your Organization

Quick JS

Here’s how you can run a small snippet of code when upon clicking the Ribbon button –

  1. Here’s the Smart Button you can use to run a snippet of JS code.

  2. When you drag the same on the ribbon (Form Ribbon in this case), you’ll be asked the below parameters – the Name of the button and the JS code you want to run.

  3. Once you’ve entered this, you can see the button show up. Finally, publish the changes and check on the actual record (or Grid based on where you have used this)

Working

Here’s how the button will act upon using Quick JS Smart Button –

  1. You can see that the button is now shown on the Form.
    I opened to Console in Dev Tools to show what the JS snippet will do (since in this example, it’s supposed to Log a message in the console).

Hope this helps!

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

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

Thank you!

Run Webhook Smart Button in Ribbon Workbench | XrmToolBox

You can even Run Webhooks from the ribbon button in Dynamics 365 CRM using the Ribbon Workbench’s Smart Buttons.

In case you haven’t yet installed Smart Buttons in your Ribbon Workbench for your organization – Here’s a post for that – Install Smart Buttons for Ribbon Workbench | XrmToolBox

Now that it’s given you might have installed Smart Buttons already, let’s review how you can use the Run Report button for your Organization

Scenario

For this example – have an HTTP Flow which I want to call using the Smart Button in Ribbon Workbench


For that matter, you can call a Webhook using Run Webhook Smart Button in Ribbon Workbench, let’s see how.

Run Webhooks button

Before we begin, add the entity-only in a Solution and then load it up into Ribbon Workbench –

  1. You can see the Run Webhook button in the Ribbon Workbench menu as below.

  2. When you drag it on the ribbon on the (on the Account Form in this example), you’ll see the below parameters pop-up.
    Title should have the title of the Button to be called on the ribbon.
    Web Hook URL should have the complete URL for the Webhook – An HTTP Flow here.
    Start Confirmation Text should have the text which should be displayed on the confirmation dialog when you trigger this button for Webhook.
    Success Callback JavaScript should have the JS snippet of what should happen if the Webhook call succeeds.
    Error Callback JavaScript should have the JS snippet of what should happen if the Webhook call fails.

  3. Once you click OK, you should see the button show up on the ribbon where you have added it.


  4. You can double-click the button here and see if you need to add any additional properties.

  5. Once you are done, you can publish your changes.

Working

Now, that the changes have been published, let’s look at the Ribbon button –

  1. When you refresh the form, you’ll see that the button has now appeared.

  2. And when you click the same, you’ll be asked the text you entered in the pop-up dialog.

  3. Once you click OK, the Webhook will be triggered and the Flow will be hit (in this example)

  4. In this scenario, it’ll only pass the id of the record.

Hope this helps!

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

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

Thank you!

Run Workflow Smart Button in Ribbon Workbench | XrmToolBox

Here’s how you can use the Run Report button from Smart Buttons in Ribbon Workbench. In case you haven’t yet installed Smart Buttons in your Ribbon Workbench for your organization – Here’s a post for that – Install Smart Buttons for Ribbon Workbench | XrmToolBox

Now that it’s given you might have installed Smart Buttons already, let’s review how you can use the Run Report button for your Organization.

Scenario

I have a Workflow which updates the Account’s Account Grade field to the value Verified


And the field to be updated is as below –

Run Workflow button

Before we begin, add the entity-only in a Solution and then load it up into Ribbon Workbench –

  1. You’ll see Smart Buttons show up in your Ribbon Workbench.

  2. When you drag the button over to the Grid (Form in this case), you’ll be given this popup window to fill in the details of what the Run Workflow button should do –
    Title should be the title of the Window.
    Workflow Name should be the text Display Name of the Workflow itself.
    Start Workflow Confirmation Text should have the text that should be displayed on the confirmation dialog when clicked on the button.
    Success Callback JavaScript should have a JS snippet of what it should do upon success.
    Error Callback JavaScript should have a JS snipped of what it should do upon error in Workflow execution.


  3. Once you click OK, this is how it will appear.

  4. And that’s it, publish your changes and reload the Page to see the Smart Button to Run the Workflow in action!

Working

Let’s see below on how this Workflow button will work –

  1. On the Account form, I can now see this button being displayed and it has it’s Run Workflow icon built in.


  2. When you click the button, you’ll be seeing this message.

  3. And when it is running, you’ll see this notification on the form.

  4. And when this is done, it’ll change the value (or whatever your workflow is supposed to do).

Hope this helps!

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

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

Thank you!

Run Report using Smart Button in Ribbon Workbench | XrmToolBox

Here’s how you can use the Run Report button from Smart Buttons in Ribbon Workbench. In case you haven’t yet installed Smart Buttons in your Ribbon Workbench for your organization – Here’s a post for that – Install Smart Buttons for Ribbon Workbench | XrmToolBox

Now that it’s given you might have installed Smart Buttons already, let’s review how you can use the Run Report button for your Organization

Run Report

Here’s how you can access the OOB report in Dynamics 365 CRM –

  1. Where you have Run Report button, like this – all the SSRS Reports are under this flyout menu.


    And then you have these reports.


  2. Now, we have have this into a direct button just for that!

Run Report button

Before we begin, add the entity-only in a Solution and then load it up into Ribbon Workbench –

  1. Now, you’ll see Smart Buttons menu within which you’ll see Run Report button

  2. Once you drag it to your Form ribbon, you’ll see a pop-up immediately asking for what the Label of the button should be and what the Report should be. Enter the name and click on the magnifying button to show reports of the Report available to use.


  3. Once you select the same correctly, you’re button will look like this

  4. Once done, Publish your changes and refresh and test the same on your Account Form.

Working

Once all the changes are Publishes, you’ll see the below –

  1. The Button you added will now show up like this.

  2. When you click it, it’ll open the Report just like you would have to do from going in the menu. This makes the whole experience so easy since the most relevant reports can be put in buttons and prioritized on the ribbon.

Hope this helps!

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

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

Thank you!

Show ribbon button only on selected sub-grid of the same entity | Ribbon Workbench | Dynamics 365 CRM

In some scenarios, you might need to show only specific buttons on a sub-grid of an entity but this sub-grid is being used at multiple places and hence, all the buttons appear in each of them and not filtered based on the purpose of the sub-grid at a specific location.

Let’s look at a scenario to understand this better!

Default Scenario

By default, you’ll see all the buttons added to sub-grid in all instances of the sub-grid for the same entity.

Expected Outcome

Let’s look at this scenario to understand better –

  1. Account has a child entity Subscriptions. Now, under Account, there are 2 sub-grids for the same child entity –
    Active Subscriptions & Past Subscriptions

  2. Now, in order to have different buttons on these like
    Active Subscriptions should show End Subscription.
    Past Subscriptions should show Reactivate.

  3. To achieve this, we’ll be using Custom Rule in Enable Enable Rules in Ribbon Workbench. Let’s review how we can achieve this.

Separate Buttons on different Sub-grid based on View

Here, the approach is to have separate buttons on the sub-grids based on the “Name of the View”. We’ll achieve this using JavaScript, let’s review how –

  1. In your Ribbon Workbench, by default you have both the buttons added.
    So first, we’ll add the condition to show the buttons only on record selection –


    The way this is implemented is that you can attach an Enable Rule to the Command of the ribbon button.


    And the actual Rule is as below

  2. Now, the way the buttons should be separated are based on the name of the view itself.

  3. In order to observe what buttons should be shown on the above view, we will go the Custom Rule approach in Ribbon Workbench for the Enable Rule which is tied to the Command itself (which in turn, is attached to the actual button).
    For Inactive View, the below Enable Rule will be applied.

    And for Active Subscription grid, we’ll use the below Enable Rule which is meant for Active Subscriptions view.

  4. And, in one of the Custom Rules, you’ll see that we are calling a JS function which will check whether to return True or False based on what View the button is being run on.
    In the below Enable Rule, we are adding a Custom Rule which is calling a JS function and we are passing the current SelectedControl parameter (in this case, it’s the view itself!)

  5. And the function looks like below –
    It’ll return if the current View is the one intended.
    In the below example, we are reading what the selectedControl is – And if it matches the one we want to match to i.e. the intended Enable Rule, the True or False value are set based on the same.


    And that’s how you can have each Command in RibbonWorkbench work off of different JS functions which identifies the current View that the Command’s button is present on.

    And once this works, you’ll see the correct buttons show up on either of the views as required.


Code Samples

Here are the code samples which you can copy and modify for your own experiment –

oSubscriptionFormCustomization = {

    forActiveSubscriptionView: function (selectedControl) {
        "use strict";
        debugger;
        var currentGridName = selectedControl._controlName;
       
      
        var excludedPayRun = "ActiveSubscriptions";
        if (currentGridName == excludedPayRun) {
         return true;
        } 
    else { return false; }
    },
    
    forInactiveSubscriptionView: function (selectedControl) {
        "use strict";
        debugger;
        var currentGridName = selectedControl._controlName;
      
      
        var excludedPayRun = "InactiveSubscriptions";
        if (currentGridName == excludedPayRun) {
         return true;
        } 
    else { return false; }
    }
};      

Hope this was useful!

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

  1. Blocking Attachment Extensions in Dynamics 365 CRM
  2. Upgrade Dataverse for Teams Environment to Dataverse Environment
  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!

Ribbon button visibility based on a null value in field in Dynamics 365 | Ribbon Workbench

In case you are using ValueRule already for showing / hiding a ribbon button, but wondering how you can check for the same field for null values i.e. showing the ribbon button only when the field contains data?

I’ll explain in this post –

You can also refer this post for showing/hiding button based on a certain value – https://d365demystified.com/2021/01/08/ribbon-button-visibility-based-on-a-field-value-in-dynamics-365-ribbon-workbench/

ValueRule

Let’s consider an example where you want to show a Subscription button based on the Group Code field on the Account form –

  1. I have a Group Code button on the Account Form, if this contains data, only then the Subscription button/flyout button should show.

  2. So, in the Ribbon Workbench, you can select your button and start by adding a Display Rule (Assuming you don’t have other Display Rules already set which you’ll need to take care of)

  3. In the Display Rule, you can select the type as ValueRule

  4. In the value Rule, the field you are checking for in this example is Group Code (Name: cf_groupcode)


    At this point, if I leave the Value as blank in the above screenshot, the button will be hidden if the value is blank in the above shown Display Rule. This acts as Show when “Group Code Does Not Contain Data

    In this case, the button will be shown when the Group Code field is blank.


    And hidden when the Group Code field Contains Data


  5. Now, if we choose to Invert Result, you’ll get this – This will act as Show when “Group Code Contains Data


    Now, in this condition, the Ribbon button will be shown is the Group Code has data in it.


    And will be hidden when the Group Code field is blank.

Also Ensure

If you are wondering if your changes are being applied, also cross check the below two points –

  1. The Command must be attached to the button.

  2. And the DisplayRule must be attached to the Command itself.

Hope this was useful!

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

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

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!

Show custom ribbon button based on Security Role of the logged in User in Dynamics 365 | Ribbon Workbench in XrmToolbox

In ribbon button customization, it is a common scenario to show the button only to a certain set of users who have a certain security role.

Security Role Scenario

  1. Let’s assume Subscription Manager is a security role in your Dynamics 365.

  2. And the Ribbon button will only be visible to the Users who have been assigned this Security Role.

  3. If they have this Role, they’ll be able to see the button as below

  4. And, if the Role is not assigned, the logged In user won’t be able to see the Button.

  5. See below that in this case, the button will not show up.


JavaScript Code to check assigned Security Roles to the logged in User

  1. Since we are going to use a CustomRule further in the Ribbon Workbench to pick a true or false value based on whether the logged in user has a Security Role or not, let’s write a quick JavaScript function to provision the same.

Tip: Make sure you now pass the PrimaryControl (context) to any JS functions and avoid using Xrm.Page since the same has been deprecated.

// JavaScript source code
contactFormCustomization = {
    checkSubscriptionAccess: function (context) {
        "use strict";
        debugger;
        var currentUserRoles = context._globalContext._userSettings.securityRoles;
        var roleId = "BA69EA1F-A76E-EB11-A812-000D3A1948AB"; // Subscription Manager role
        roleId = roleId.toLowerCase();
        // Get all the roles of the Logged in User.
        
        for (var i = 0; i < currentUserRoles.length; i++) {
            var userRoleId = currentUserRoles[i];
            if (userRoleId == roleId) {
                // Return true if the Role matches
                return true;
            }
        }
        return false;
    }
    
};

Refer this post which discusses a simple JavaScript function to use in order to check if the logged in User has a certain security role or not – https://medium.com/capgemini-microsoft-team/dynamics-365-v9-verify-logged-in-user-security-role-using-typescript-2de52f2ef04e

Explanation

  1. Hard-code the GUID of the Security Role which you are looking to check.
  2. Then read all the Security Roles assigned to the user.
  3. Once the Security Roles are found in the logged in User’s Security Role, return true. Else, return false.

Ribbon Button – Enable Rule

Let’s see how the button customization will look like in XrmToolBox’s Ribbon Customization –

  1. In Ribbon Workbench, you need to add a CustomRule under Enable Rules for the Ribbon button.

  2. Then, it asks for the JavaScript function (mention the function which returns a simple true or false based on above steps). and then mention the library –
    Also, pass the context PrimaryControl and using the same, pick the Security Roles of the logged in user as mentioned in the JS code explanation above.
    I’m naming my Enable Rule as SecurityRoleCheck.

    Now, the CustomRule I’ve applied will call the JS function and is expected to receive either a true or a false based on the code. If false – the button will not be enabled, if true – the button will be enabled.


  3. Now, make sure you add this Enable Rule to the Command (which is in-turn attached to the Ribbon Button itself)

Hope this was helpful. Here are some more XrmTool / Ribbon Button customization related posts you might find helpful –

  1. Ribbon button visibility based on a field value in Dynamics 365 | Ribbon Workbench
  2. Get GUID of the current View in Dynamics 365 CRM JS from ribbon button | Ribbon Workbench
  3. Pass Execution Context to JS Script function as a parameter from a Ribbon button in Dynamics 365 | Ribbon Workbench
  4. Pass selected rows’ GUIDs to ribbon button in D365 | Ribbon Workbench
  5. Debug Ribbon button customization using Command Checker in Dynamics 365 CE Unified Interface
  6. Show Ribbon button only on record selection in Dynamics CRM
  7. Hide Custom Ribbon Button [Easy Way] – Ribbon Workbench
  8. Enable Flow button on D365 Ribbon
  9. [SOLVED] Navigating URL from Ribbon’s custom button in Dynamics for Phones app
  10. Fix Ribbon icons on the Unified Interface in D365 CE
  11. Connecting XrmToolBox to an MFA enabled Dynamics 365 environment | Azure AD
  12. Find deprecated JS code used in your Dynamics 365 environment | Dynamics 365 v9 JS Validator tool | XrmToolBox

Thank you!!