PL 400 : design command button rules and actions (Create a command button function)

Creating or modifying command buttons in Dynamics CRM is always a challenge, with the developer usually using the Ribbon workbench(much respect to the creator) for such activities. Modern Command Designer is a great initiative by Microsoft to reduce the complexity of this process and introduced the No/Low Code Designer where developers can define button behavior with Power Fx and JavaScript.


When the Entity view with multiple records is displayed, this command bar presents all the navigational options for a specific entity. Navigation elements can provide some functionality to the entire group of records displayed.

There are three entity-specific command bars:
  • Main grid command bar
  • Entity form command bar
  • Entity sub-grid command bar

A ribbon command defines three things:

Enable Rules: Specifies when a specific ribbon control is enabled.
Display Rules: Specifies when a specific ribbon element is visible.
Actions: Specifies what code executes when a ribbon control is used.

Enable Rules:

Enabled rules are intended to be reused. By defining them with rule definitions, we can use the same enable rule for multiple command definitions. When more than one enable rule is defined for a command definition, all enable rules must evaluate as true to enable the ribbon element. All Enable rules provide an optional parameter to specify whether the default value of the rule is true or false and an optional InvertResult parameter to allow for returning a negative result when the item being tested returns true. Custom rules that do not return a value quickly can affect the performance of the ribbon.

Display Rules:

By defining display rules in rule definitions, we can use the same display rule for many command definitions. When more than one display rule is defined for a command definition, all of the display rules must evaluate as true for the ribbon element to be displayed. All display rules provide an optional attribute to specify whether the default value of the rule is true or false and an optional InvertResult attribute to enable returning a negative result when the item being tested returns true.

Action:

Define the actions to be performed by a command bar or ribbon control in a <CommandDefinition> element together with rules that control whether the control is enabled or visible in the ribbon.

A Ribbon control can perform two types actions and may include multiple actions:
  • JavaScript Functions: A <JavaScriptFunction> element references a function defined in a Script Web resource.
  • Open a URL: The ribbon opens a URL using the value from an Address attribute in the <Url> element. Additional parameters can pass information about how what querystring parameters are passed and the mode in which the window opens.

Comments

Popular posts from this blog

Exploring the Differences: Managed vs. Unmanaged Solutions in Dynamics CRM/Dataverse

PCF vs. Web Resources: Choosing the Right Extensibility Tool for Dataverse

Effective Strategies for Debugging Plugins in Dynamics CRM