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.
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.
- Navigate to
Settings
|Solutions
|Packt
. - Under
Processes
, click onNew
. - Fill in the following details:
Process name
:Create Student
Category
:Action
Entity
:None (global)
- Click on
OK
. - Click on the
+
button belowHide Process Arguments
and add the following four arguments:Name
:FirstName
,Type
:String
, andDirection
:Input
Name
:LastName
,Type
:String
, andDirection
:Input
Name
:EmailAddress
,Type
:String
, andDirection
:Input
Name
:CreatedStudent
,Type
:EntityReference
,Entity
:Contact
, andDirection
:Output
- Click on
Add Step
|Create Record
. - In the drop-down next to
create
, selectContact
and click onSet Properties
.
- Enter the following details:
First Name
: From the right form assistance, selectArguments
in theLook For
dropdown, followed byFirstName
in the drop down, click onAdd
, and thenOK
Last Name
: From the right form assistance, selectArguments
in theLook For
dropdown, followed byLastName
in the drop down, click onAdd
, and thenOK
Email Address
: From the right form assistance, selectArguments
in theLook For
dropdown, followed byEmailAddress
in the dropdown, click onAdd
, and thenOK
Contact Type
:Student
- Click on
Save
andClose
. - Click on
Add Step
|Assign Value
. - Select
Set Properties
next toAssign Value
. - Enter the following details:
Statement Label
:Assign a created student
Name
:Created student
- Go to
Value
from the right-handForm Assistance
and selectCreate (Contact)
from theLook For
dropdown andContact
from the next drop down - Click on
Add
andOK
, and thenSave and Close
- Click on
Activate
and thenSave and Close
:
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.
The Creating your first custom action recipe of Chapter 4, Server-Side Extensions