Wednesday 15 February 2017

MICROSOFT DYNAMICS CRM WORKFLOW ACTIVITY.


CUSTOM WORKFLOW ACTIVITIES


-Allows building custom steps that are available for use in the web workflow designer.

-Built on Windows Worklfow Foundation V4.

-Work for on-premise and CRM online deployments

- Can be used in workflows or dialogs.

--------------------------------------------------------------------------------------------------------------------------

Overview of CRM Workflows


-- Rule: Define the logic that is executed when a specific triggering event occurs on a record.

-- Events: Assign, Attributes Chnage(Update), Change Status, Create, Delete and On Demand

--Conditions: Check values to provide rules for what actions to perform.

--Actions: Create Record, Update Record, Assign Record, Send Email, Start Child Workflow, Change Status, Stop Workflow

--------------------------------------------------------------------------------------------------------------------------

OVERVIEW OF CRM DIALOGS


-Input Arguments: Data that is passed from  a parent dialog.

-Variable: Store intermediate values as users move through the dialog.

-Pages: Provides the body of the dialog by adding prompts and responses

-Prompts & Responses: Poses a question to a user and captures the response.

-Actions & Conditions: Checks values and performs specifics tasks.

--------------------------------------------------------------------------------------------------------
WORKFLOW EXECUTION WITH CUSTOM ACTIVITIES

   Workflow
 step1 -Check Condition
 step2 - Update Record
 step3 -Your Custom Activity

--------------------------------------------------------------------------------------------------------------------------

CUSTOM ACTIVITY SCENARIOS


-Complex calculation

-Performing actions on child records

-Pull a customer's credit score from a 3rd party to be used for loan approval

-Any Integration with other systems called on demand.

- Any scenario where you want to surface custom code in the CRM workflow editor.





CUSTOM WORKFLOW ACTIVITY CLASS DIAGRAM


Without Developer Toolkit

--CodeActivity Class

--Your Custom Class

--code example:

public sealed partial class CustomActivity : CodeActivity
{
   protected override void Execute(CodeActivityContext executionContext)
{

}
}




With Developer Toolkit


--CodeActivity Class

--WorkflowActivityBase Class

--Your Custom Class

--code example:

public sealed partial class CustomActivity : CodeActivity
{
public override void ExecuteCRMWorkflowActivity(CodeActivityContext executeContext, LocalWorkflowContext crmWorkflowContext)
{

}
}

--------------------------------------------------------------------------------------------------------------------------

WORKING WITH PARAMETERS


-Used to configure a workflow activity
- Exposed via the worklfow editor

-CRM supports two types
   -- input and ouput

--Values are populated at time of execution of cutom activity

The DefaultAttribute class allows you to specify a default value for an input parameters

Declaring Parameters

[RequiredArguments]
[Input("InputEntity")]                    -------------1
[ReferenceTarget("account")]

public InArgument<EntityReference> inputEntity {get; set;}
[Output ("TaskCreated")]
[ReferenceTarget("task")]            -----------------2

public OutArgument<EntityReference> taskCreated  {get; set;} -----3

protected override void Execute(CodeActivityContext executeContext )
{

}

--------------------------------------------------------------------------------------------------------------------------

Getting and Setting Parameters Values


Setting and getting values must is done using the Set/Get methods and referencing the execution context

Guid accountId = this.inputEntity.Get(executionContext).Id;

this.taskCreated.Set(executionContext, new EntityReference("task", taskId));



-------------------------------------------------------------------------------------------------------------------------

Working with services


The Workflow ExecutionContext.GetExtension method provides access to the CRM services like

--Organization Service

--Tracing Service

IWorkflowContext context = executionContext.GetExtension<IWorkflowContext>();

IOrganizationServiceFactory serviceFactory = executionContext.GetExtension<IOrganizationServiceFactory>();

IOrganizationService service = serviceFactor createOrganizationService(context.UserId);





Working with Services using Developer Toolkit


public class CustomWorkflowActivity : WorkflowActivityBase
{
    public override void ExecuteCRMWorkflowActivity(CodeActivityContect executionContext, LocalWorklfowContext crmWorkflowContext)
{
     crmWorkflowContext.Trace("Plug-in is Starting");

var  whoamiResult  = crmWorkflowContext.OrganizationService.Execute(new WhoAmIRequest());
}
}
























No comments:

Post a Comment

Note: only a member of this blog may post a comment.