Overview
This article shows how you can execute a North52 Decision Table as part of a Flow and return a value back to the Flow to be used in a later step. This is conceptually very similar to how the Process Genie functionality works for standard Dynamics 365 workflows.
The business scenario is that we need to create a Dynamics 365 Task record with a due date at the end of the month. At the time of writing, there is no easy way to do this with regular Flow functionality but it can be easily achieved with a North52 function.
This concept can be extended for use in much more complex scenarios than the example shown below. This article is a simplification of a previous article that used an Azure Web Application for authentication, we can now use an HTTP with Azure AD action to simplify the process.
North52 Decision Suite
The North52 Decision Suite solution works like this:
- A Custom Action is set up with a single Output parameter
- A Formula is set up on the Custom Action which returns the last day of the month using the GetLastDayOfMonth function
- A Microsoft Flow is set up to:
- Call the Custom Action via the Web API and retrieve the last day of the month value
- Create a new Task record with Due Date set to the value returned from the Custom Action
Set up Global Action, Formula and Flow
This example requires a number of components to be set up; a Global Action, a North52 Formula and a Microsoft Flow.
Global Action
We need to set up a Global Action process which will then use a North52 formula to return a value in the output parameter.
- Navigate to Settings > Processes
- Click New to create a new Process:
- Enter Last Day of Month for the Name
- Select Action from the Category list
- Select None (global) from the Entity list
- Click OK
- On the Process form window which opens:
- Click the + (Add) button in the Process Arguments section
- Type Output for the Name replacing the default NewArgument text
- Select DateTime from the Type list
- Select Output for the Direction
- Click Save
- Click Activate
Formula
For this simple example there are no Conditions and a single Action. However, this same method can be used to call Actions with complex business rules.
- Create a new Formula, setting the following values in the Formula Guide:
- Source Entity set to N52 Command
- Set Formula Type to Action
- Select the Decision Table editor
- Change the Name of the formula to Action - Last Day of Month
- Set the Action Event to new_LastDayofMonth (your Action from the Global Action section above)
- Click Save
- Right-click on the Decision Table sheet, select Set Sheet Options and check Use Action
- Select column A, right-click and select Delete > Delete Column to remove the Condition column
- Select cell A2
- Go to the Source tab and expand Processes > Actions > none > new_LastDayofMonth and select Out: Output ( DateTimeOffset- false )
- Note that the "none" node is for Global Actions (i.e. is no Entity associated)
- Select cell A4
- Select the Functions tab, type getlast into the Search Functions input box and press enter
- Shift-click on the GetLastDayOfMonth function to open the function wizard:
- Leave the Friendly Name blank as we will insert the function directly into the cell
- Put the cursor into the Input Date field, then replace the previous function search by typing utc into the Search Functions input box and press enter
- Select the UtcDate() function to add it to the Input Date field
- Leave Offset blank
- Click Generate
- Click Save
Flow
- Go to https://flow.microsoft.com/manage/flows/
- Select New > Create from Blank
- In the top left of the screen replace Untitled and rename your flow to Create Task with End of Month Due Date
- Enter manually trigger in the Search all connectors and triggers input box
- Select the Flow button for mobile - Manually trigger a flow trigger
- Select + New Step
- Enter http in the Search all connectors and actions input box
- Select the HTTP with Azure AD action, then select the Invoke an HTTP request option, configuring it as follows:
- Select the ... menu option Rename
- Enter Call North52 Decision Table via Custom Action
- Method: select Post
- URI: enter the Instance Web API Service Root URL from Settings > Customizations > Developer Resources, followed by the schema name of your Action:
- e.g. https://tenant.crm.dynamics.com/api/data/v8.2/new_LastDayofMonth
- Select the ... menu option Rename
- Select + New Step > Add an action
- Enter parse in the Search all connectors and actions input box
- Select the Parse JSON - Data Operations action
- Content: select Body from the Dynamic Content, under the Call North52 Decision Table via Custom Action section
- Schema: enter the follow JSON schema:
{ "type": "object", "properties": { "Output": { "type": "string" } } }
- Select + New Step
- Enter dynamics in the Search all connectors and actions input box
- Select Dynamics 365 - Create a new record
- Select the ... menu option Rename
- Enter Create a new Task record with Due Date end of month
- Organization Name: select you Dynamics 365 organization you wish to create your record in (you may need to add a new connection first)
- Entity Name: select Tasks
- Subject: enter New Task from Flow: Due followed by a space and then select Output (under Parse JSON section) from the Dynamic content options
- Select Show advanced options
- Due Date: select Output (under Parse JSON section) from the Dynamic content options. You may need to select the See more option
- Save your Flow
Testing
While in the Flow editor click the Test button from the top right of the screen and follow the instructions. Ensure that there are no errors and verify that the Task has been created in Dynamics 365.