Wednesday, 12 October 2016

Custom Workflow

What is custom workflow ?

Custom workflow extend the steps of  workflow which is by default available in the CRM.By default certain  functionality like create and update assign a record, send email .But in in case if you need to do the things more than this than we can go for custom workflow.

It is dll which is generated by creating class in VS.

Company ABC used to get many leads that are auto generated  on weekends but none of their sales executive wants to work on weekends so for this they hired a part time sales executive.

So we have requirement that whenever lead is created on weekend it should get assigned to this lead and it should show created day  in leads record.

1.Want to display record craeted day in lead record
2.If lead created on sunday then assign it to specific lead.

Lets start
Step 1 - Go in VS 2012 - select  new --> select workflow---> Activity Library   and give name.
By default Activity.xml  delete this.

Step 2 - Add Microsoft.Xrm.SDK, Microsft.Xrm.Workflow, Microsoft.Crm.sdk.proxy
serialisation

step 3 Add new Class give proper name


Using Microsoft .xrm.sdk.query
Using Microsoft .xrm.sdk
Using Microsoft .xrm.sdk.message
using System.Activities

namespace LeadAssignment
{
     public class LeadAssignment:CodeActivity
     {
     [Output("Dayofweek")]
     public OutArguments<string> DayofWeek {get;set;}
   
     public override  void Execute (codeActivityContext, Execution)
      {
            string Day = String.Empty;
            DateTime date = DateTime.MinValue;
           Iworkflowcontext context = Execution.GetExtension<IworkflowContext>();
          IorganisationServiceFactory  serviceFactory  = Execution .Get Extension<Iorganisation>
       }
}




No comments:

Post a Comment