Views:

Overview

In this article, we will use North52 Quick Ribbon to execute a formula against a selection of records in a list view. The formula will be called only once, and each of the record Guids will be passed into the formula as a parameter. As this article is purely for demonstration purposes, all we will do here is update the description field of an account with the current date and time.

North52 BPA Solution

The North52 BPA solution works like this:

  • A Quick Ribbon button is added to the list view of Accounts
  • A Formula of type ClientSide - Calculation is configured on the Account
    • The formula will update the description field with the current date and time.

North52 Formula

  • Create a new formula, setting the following values in the Formula Guide:
    • Source Entity set to Account
    • Set Formula Type to Client-Side Calculation
    • Select the Decision Table editor
  • Change the Name of the formula to Account - Set Date and Time
  • Click Save 
  • Right-click on the Decision Table and select Select Sheet Options > Use UpdateCreateRecordById 
    • This will allow us to tell our ForEachRecord function later what records we are going to update
  • Right-click on cell A1 and select ForEachRecord and set the name to be Loop Over Accounts 
  • In cell A3 (press F4 on your keyboard if not visible)
    • Quick Ribbon will pass the selected values into the formula using the virtual field n52gridentitycollection 
    • We use the function ConvertListToEntityCollection to convert this virtual field into an in-memory collection that we can loop over: ConvertListToEntityCollection([account.n52gridentitycollection], '|')  
    • Our ForEachRecord function will now loop over each record in the AccountCollection we created
  • Columns B and are Actions
    • Click on B2 and then select Account from the Source Tab
    • Click on C2 and then select Description from the Source Tab
  • Enter CurrentRecord('id') into B4 
  • Click on C4 and select UtcDateTime() function from the functions list
  • Click Save 

Step 2: Add the Quick Ribbon to the entity using Ribbon Workbench

  • Open Ribbon Workbench and connect to your instance of Dynamics 365
  • We have created a solution with just the Account entity added to it:

Command

  • Configure a Command by clicking on the + icon. Change the name to north52.account.demo.Command
  • The JavaScript Action will use $webresource:north52_quick_ribbon.js and the function should be set to N52QuickRibbon.ExecuteFormulaOnViewSingleCall
     
  • We will be passing in 5 parameters instead of just two:
    • Crm Parameter: PrimaryControl 
    • Crm Parameter: SelectedControlSelectedItemsIds 
    • Crm Parameter: SelectedEntityTypeName  
    • Crm Parameter: UserLcid   
    • String Parameter: shortcode of the formula

Button

  • Drag a button onto the form. Set the ID to be north52.account.listview.datetime and name it Demo Button
  • Set the Command to be the newly created command
  • The final step we need to add for a Ribbon Button on the Unified Interface is a SelectionCount rule. Detailed instructions for this are located here
  • Publish the Solution

If you want to add an icon to your button in the Unified Interface it will need to be of type svg. It will need to be specified in the 'ModernImage' field on your button.
Note: You can download svg icons from various sites on the internet or convert existing images into them using tools. When you have your svg icons ready, you will need to added them as web resources to your Dynamics instance and then you can use them in your ribbon buttons.