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 a configurable e-mail notification workflow


Workflows are one of the most powerful no-code extensions you can configure in Dynamics 365; without any code, you can automate repetitive business processes.

Workflows are versatile and can fulfill a wide range of functionalities, ranging from creating entities and sending e-mails to calling actions. In this recipe, we will create a workflow that sends an e-mail to any new students after 24 hours of their record being created.

Getting ready

Similar to the previous recipe, 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: Send Student Welcome Email
    • Category: Workflow
    • Entity: Contact
    • Tick Run this workflow in the background
    • Type: New blank process
  4. In the Process editor tick Record is created and As an on-demand. Keep the rest as is with their default values.
  5. Click on Add Step | Wait Condition.
  6. Click on <condition> (click to configure) and select the following:
    • Process in the first column
    • Execution time in the second column
    • Equals in the third column
    • In the last column, use the form assistance on the right-hand side:
      1. Select 1 under Day
      2. Select After
      3. Look for Process
      4. Double click Execution Time in the last list

 

 

  1. Click on Save and Close.
  2. Back in your process, click on Select this row and click Add Step, then click on Add Step | Check condition.
  3. Click on <condition> (click to configure) and enter the following details:
  • Contact, Email, and Contains Data
  • Contact, Contact Type, Equals, and Student (created in the previous recipe)
  • Contact, Status, Equals, and Active
  • Click on Save and Close:
    1. Click on Select this row and click Add Step, followed by Add Step | Send Email.
    2. Select Create New Message from the drop-down and click on Set Properties.
    3. Enter the details of the e-mail as follows:
    • From: <your name>
    • To: using Form Assistance on the right, select Contact under Look for followed by Contact from the next dropdown, then click on the Add button followed by the OK button at the bottom:
        • Enter Welcome to Packt University in the Subject Line option
        • Enter Hi
        • Using the right Form Assistance, select Contact, Last Name, and click on Add, then OK
        • Follow the salutation with a carriage return (Enter) and Welcome to Packt University
      1. Save and Close the dialog.

       

       

      1. Click on Activate at the top of the workflow:

      How it works...

      In step 2 to step 4, we created a workflow that triggers on creation (when the contact record is first created, the workflow will start waiting). The workflow can also be called on demand in case we want to trigger it again. In this example, the contact might already be created but not as a Student. Once the contact is set as a Student, the workflow can be triggered manually to send the welcome e-mail.

      In step 5 and step 6, we set up the wait condition to wait for a day.

      In step 7 and step 8, we checked if the contact is an active student with an e-mail address.

      In step 9 to step 12, we created a personalized e-mail for the contact and welcomed them.

      In step 13, we activated the workflow.

      Note

      As a good practice, always add descriptions to your workflow, and to each step, to understand at a high level what the workflow is doing.

      When asynchronous workflows are triggered, they enter into a pool to be processed when the asynchronous service is free. Asynchronous workflows are typically executed within seconds or minutes. If the execution is taking hours, then you might want to raise a support ticket with Microsoft to investigate. Executing workflows asynchronously is a great way to lighten the load on your Dynamics instances.

      When workflows instances are waiting for a condition to be satisfied, they do not consume resources or affect your instance's performance. However, it is generally agreed by the community that it is a bad practice to have too many workflow instances in a waiting status.

      There's more

      In more recent releases, synchronous workflows that turn your workflow into a configurable plugin became available. Microsoft does not recommend synchronous workflows for long processes due to the load that is associated with them. Furthermore, online instances have a limit of 2 minutes per synchronous workflow or plugin. Nevertheless, synchronous workflows are there to be used. Use them wisely.

      See also

      • The Creating your first custom workflow activity recipe of Chapter 4, Server-Side Extensions