Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Microsoft Dynamics 365 Extensions Cookbook

You're reading from   Microsoft Dynamics 365 Extensions Cookbook Add functionality to existing model elements, source code and finally package and deploy using DevOps

Arrow left icon
Product type Paperback
Published in Jun 2017
Publisher Packt
ISBN-13 9781786464170
Length 462 pages
Edition 1st Edition
Languages
Tools
Concepts
Arrow right icon
Author (1):
Arrow left icon
Rami Mounla Rami Mounla
Author Profile Icon Rami Mounla
Rami Mounla
Arrow right icon
View More author details
Toc

Table of Contents (12) Chapters Close

Preface 1. No Code Extensions FREE CHAPTER 2. Client-Side Extensions 3. SDK Enterprise Capabilities 4. Server-Side Extensions 5. External Integration 6. Enhancing Your Code 7. Security 8. DevOps 9. Dynamics 365 Extensions 10. Architectural Views 11. Dynamics 365

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

You have been reading a chapter from
Microsoft Dynamics 365 Extensions Cookbook
Published in: Jun 2017
Publisher: Packt
ISBN-13: 9781786464170
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image