Book Image

Microsoft Dynamics 365 Extensions Cookbook

Book Image

Microsoft Dynamics 365 Extensions Cookbook

Overview of this book

Microsoft Dynamics 365 is a powerful tool. It has many unique features that empower organisations to bridge common business challenges and technology pitfalls that would usually hinder the adoption of a CRM solution. This book sets out to enable you to harness the power of Dynamics 365 and cater to your unique circumstances. We start this book with a no-code configuration chapter and explain the schema, fields, and forms modeling techniques. We then move on to server-side and client-side custom code extensions. Next, you will see how best to integrate Dynamics 365 in a DevOps pipeline to package and deploy your extensions to the various SDLC environments. This book also covers modern libraries and integration patterns that can be used with Dynamics 365 (Angular, 3 tiers, and many others). Finally, we end by highlighting some of the powerful extensions available. Throughout we explain a range of design patterns and techniques that can be used to enhance your code quality; the aim is that you will learn to write enterprise-scale quality code.
Table of Contents (19 chapters)
Title Page
Credits
Foreword
About the Author
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface

Building your first action


Have you ever wanted to call a workflow from your JavaScript? If you have, then you will be pleased to learn about Actions. Actions, introduced with Dynamics CRM 2013, are yet another great addition to the configurable extensions. It was created to allow a business logic to be called from within workflows, as well as from JavaScript and Plugin customization.

Actions can be built using a point and click interface, as well as using .NET code. In this recipe, we will create a configured action that takes a few string values, creates a student record, and returns that record as an output parameter.

Getting ready

Similar to the previous recipes, a System Customizer or higher security role is required to perform the configuration as well as a solution to contain the changes.

How to do it

  1. Navigate to Settings | Solutions | Packt.
  2. Under Processes, click on New.
  3. Fill in the following details:
    • Process name: Create Student
    • Category: Action
    • Entity: None (global)
  4. Click on OK.
  5. Click on the + button below Hide Process Arguments and add the following four arguments:
    • Name: FirstName, Type: String, and Direction: Input
    • Name: LastName, Type: String, and Direction: Input
    • Name: EmailAddress, Type: String, and Direction: Input
    • Name: CreatedStudent, Type: EntityReference, Entity: Contact, and Direction: Output
  6. Click on Add Step | Create Record.
  7. In the drop-down next to create, select Contact and click on Set Properties.

 

 

  1. Enter the following details:
    • First Name: From the right form assistance, select Arguments in the Look For dropdown, followed by FirstName in the drop down, click on Add, and then OK
    • Last Name: From the right form assistance, select Arguments in the Look For dropdown, followed by LastName in the drop down, click on Add, and then OK
    • Email Address: From the right form assistance, select Arguments in the Look For dropdown, followed by EmailAddress in the dropdown, click on Add, and then OK
    • Contact Type: Student
  2. Click on Save and Close.
  3. Click on Add Step | Assign Value.
  4. Select Set Properties next to Assign Value.
  5. Enter the following details:
    • Statement Label:  Assign a created student
    • Name: Created student
    • Go to Value from the right-hand Form Assistance and select Create (Contact) from the Look For dropdown and Contact from the next drop down
    • Click on Add and OK, and then Save and Close

 

 

  1. Click on Activate and then Save and Close:

How it works...

In step 2 and step 3, we created the blank action. We ensured that the action's entity is set to None (global), meaning that the process is not bound to any entities (the way workflows are).

In step 4, we created three input parameters and one output parameter.

In step 5 to step 7, we created the student contact record using the input parameters.

In step 8 to step 10, we assigned the created record to the output parameter.

In step 11, we activated the process.

As mentioned previously, actions can be called from workflows, JavaScript, Plugins, or using the Dynamics 365 web services. Every time an action is created, Dynamics 365 creates a message that can be called externally. In the Creating your first custom action recipe in Chapter 4, Server-Side Extensions, you will learn how to generate early-bound types for actions to call using managed .NET code.

Microsoft recommends naming your action using a verb describing what the action is about to ensure your application's vocabulary is something that makes sense from a business flow perspective.

For more information about actions, visit https://technet.microsoft.com/en-us/library/dn531060.aspx.

See also

The Creating your first custom action recipe of Chapter 4, Server-Side Extensions