Views:

Scenario Overview

In this example, we will show how to use North52 BPA in conjunction with a Custom Global Action.

The main advantages to this type of solution,

  • Allows us to develop custom logic that is not tied to any entity in CRM. 
  • Using the Microsoft WebAPI, we can call this custom Global Action from any C# or javascript code along with normal Workflows, BPFs, etc. inside Dynamics 365

The following are the steps that we are going to implement for this solution,
  • We will first create an Action with 3 inputs and 2 output parameters. 
  • We will then create a North52 formula that will set the output parameters.
  • Finally we will set up CRM REST Builder to allow us to make our "Hello World Contact "custom Action.
    • You can download CRM REST builder here


Note 1: For more information on Custom Actions and their uses,  please see this article  from a Microsoft MVP
Note 2 : Execute an action using the Web API 
Note 3 : Execute an action using the organization service

Create Custom Action

 
  • Go to Settings > Process
  • Click on New
  • For Process Name , enter "Hello World - Contact Type"
  • For Category, select 'Action'
  • For Entity, select 'None (global)'
  • Click Ok
  • Click on the Plus sign (under Hide Process Argument) to add a Process Argument. 
  • For its Name, type "FirstName"
  • Set Type to 'String'
  • For Direction, leave it at 'Imput'
  • Tick Required
  • Click on the Plus Sign again. 
  • For its Name, type "LastName"
  • Leave Type at 'String'
  • For Direction, leave it at 'Input'
  • Click on the Plus Sign again. 
  • For its Name, type "ContactType"
  • Leave Type at 'String'
  • For Direction, leave it at 'Input'
  • And now we do the outputs.
  • Click on the Plus Sign again. 
  • Give it the name "FirstActionResult"
  • Leave Type at 'String'
  • Set Direction to 'Output'.
  • Click on the Plus Sign again. 
  • Give it the name "SecondActionResult"
  • Set Type to 'String. 
  • Set Direction to 'Output'.  
  • Click Save
  • Click Activate

N52 Formula Manager Steps

 

The following set of steps assumes you are just using the out of the box Dynamics CRM setup. But its easy to enhance if you have extra fields \ requirements.

  • Create a new Decision Table of type 'Action'
  • Set the Action Event field to 'new_HelloWorldContactType'
  • Set the Source Entity to 'N52_Command'
    • We choose this Source Entity as the system needs an Entity to run off even though the Action is independent of Entities here. 
  • Click onto the Decision Table (if you are in Formula Editor mode, click on Commands > Toggle Editor
  • Right click on the sheet
  • Tick Set Sheet Options > Use Action





 
  • Right click B2
  • Select Insert > Insert Action
  • Click on cell A2
  • Go to the Source tab and expand Processes > Actions > none > new_HelloWorld > In : ContactType (String - false ) 
    • Note that the "none" part is due to there is no Entity associated with the Action
  • In cell A4 , type 'Customer'
  • In cell A5, type 'Partner'
    • This tells the formula that if the Contact Type is Customer , perform theActions in row 4
    • If the contact type is Partner, perform the Actions in Row 5
    • If it is neither, perform row 6. This is something to keep in mind, you should allow for catch all rows in your decision table when needed. 
  • Click on cell B2
  • Go to the Source tab and expand Processes > Actions > none > new_HelloWorld > Out: FirstActionResult  (String - false ) 
  • Click on B4 and type 'Hello World , my name is ' + 
  • Go to the Source tab and click on In: FirstName (String - false ) 
  • Add another + and then add a ' ' and finally go to the source tab and click on In :Last name (String - false ) 
    • what we have done here is set the FirstActionResults Output to be a string that says Hello World, my name is FirstName LastName
  • Copy and paste cell B4 into cell B5 and B6
  • Click into cell B5 and B6 and replace "World" with "Earth" and "Universe" respectively.
  • Click on cell C2 
  • Go to the Source tab and click on Out : SecondActionResult (String - false ) 
  • Copy the corresponding string below into their corresponding Cells.  
    • Cell C4 :   'and I am a ' + [north52_command.ContactType]
    • Cell C5 : 'and I love being a ' +[north52_command.ContactType]
    • Cell C6 :  'and I am not a partner or a customer , I am a  ' + [north52_command.ContactType]
  • Click Save
  • Ready to test


Import CRM REST Builder / Hello World. 

 
  • If you haven't already, download  CRM REST Builder here
  • Go to Settings > Solutions and Import it. 
  • Wait for it to finish
  • Go to Settings > Solutions
  • Click on CRM REST Builder. 
  • Under Action , select 'Action'
  • Under the second Action, select 'new_HelloWorldContactType'
  • For First Name, enter a name. 
  • For Last Name enter a last name
  • For Contact Type enter either 'Partner',  'Customer' or something different. 
  • Click Create Request
  • Click on Execute Code
  • See results. 
    • Note that by changing the Contact Type around, you can get the different results.