Creating and Executing a Custom Action and Early Bound Class in Dynamics 365: A Step-by-Step Guide

Creating and Executing a Custom Action and Early Bound Class in Dynamics 365: A Step-by-Step Guide

Table of Contents

Introduction

In this blog post, we’ll walk you through the process of creating and executing a custom action and Early Bound Class in Dynamics 365. We’ll cover everything from creating the custom action and generating early bound classes to writing the plugin code and executing the action via workflow. Let’s get started!

Creating the Custom Action

The first step in our process is to create a custom action with the necessary input and output parameters. This allows us to define the operation we want to perform and specify the data that will be used and returned.

Steps:

1. Navigate to the Solution in Dynamics 365.

2. Create a new Action in the Processes section.

3. Define the Input and Output parameters. For this example, we used:

    Input Parameters: `Money1` Type (Money), `Money2` Type (Money), `Target` Type (Entity Reference)

    – Output Parameter: `MoneySum` Type (Money)

Creating the Custom Action

Generating Early Bound Classes

Next, we need to generate early bound classes using the XRM Toolbox.

Steps:

1. Open XRM Toolbox and open the Early Bound Generator V2 Tool.

2. Add the custom action to the Message Whitelist.

3. Generate the early bound classes.

Generating Early Bound Classes
Creating and Executing a Custom Action and Early Bound Class in Dynamics 365: A Step-by-Step Guide

Writing the Plugin Code

With the early bound classes in place, we can now write the plugin code to perform the functionality. This involves calculating the sum of the input money values and setting the result in the output parameter.

Steps:

1. Create a new class that implements the `IPlugin` interface.

2. Retrieve and validate the input parameters.

3. Perform the sum calculation.

4. Set the result in the output parameter.

5. Register the plugin.

Here’s a snippet of the plugin code:

CSharp (C#):

Writing the Plugin Code in Dynamics CRm with csharp (c#)
Writing the Plugin Code

Registering the Plugin

After writing the plugin code, the next step is to register the plugin using the Plugin Registration Tool.

Steps:

1. Open Plugin Registration Tool.

2. Register the new plugin assembly.

3. Add a step for the plugin and set the message to the custom action created earlier.

Registering the Plugin

Executing the Action via Workflow in Dynamics CRM

Finally, we use a workflow in Dynamics 365 to trigger the custom action. This allows us to automate the execution of our custom actions based on specific criteria.

Steps:

1. Create a new Workflow in Dynamics 365.

2. Add a step to Perform Action. 3. Set the input fields with the appropriate values, including the quote entity reference

Executing the Action via Workflow in Dynamics CRM

Conclusion

By following these steps, you can create and execute a custom action in Dynamics 365. This process involves creating the action, generating early bound classes, writing the plugin code, registering the plugin, and finally, triggering the action via workflow. With these tools and techniques, you can extend the functionality of Dynamics 365 to meet your unique business requirements.

Readmore : optimizing ecommerce operations with dynamics crm

FAQ’s

What are the input and output parameters required for creating a custom action in Dynamics 365?

When creating a custom action in Dynamics 365, you need to define both input and output parameters. For example:
Input Parameters: Money1 (Type: Money), Money2 (Type: Money), Target (Type: Entity Reference)
Output Parameter: MoneySum (Type: Money) These parameters allow the action to perform calculations or operations and return the results.

How do I generate early bound classes for my custom action using XRM Toolbox?

To generate early bound classes for your custom action using the XRM Toolbox:
Open the XRM Toolbox.
Use the Early Bound Generator V2 Tool.
Add your custom action to the Message Whitelist.
Generate the early bound classes. This process provides a strongly-typed representation of your custom action, simplifying the development process.

How can I register and execute a plugin for a custom action in Dynamics 365?

To register and execute a plugin for a custom action in Dynamics 365:
Open the Plugin Registration Tool.
Register the new plugin assembly.
Add a step for the plugin and set the message to the custom action created earlier. To execute the action, create a new workflow in Dynamics 365, add a step to perform the action, and set the input fields with the appropriate values.

Picture of SkySoft Connections

SkySoft Connections

SkySoft Connections is a software solution company that was established in 2016. Our quality services begin with experience and end with dedication. Our directors have more than 15 years of IT experience to handle various projects successfully. Our dedicated teams are available to help our clients streamline their business processes, enhance their customer support, automate their day-to-day tasks, and provide software solutions tailored to their specific needs. We are experts in Dynamics 365 and Power Platform services, whether you need Dynamics 365 implementation, customization, integration, data migration, training, or ongoing support.

Conatct us