Search This Blog

Friday, July 15, 2011

CRM 2011 Custom workflow


Today I was working on custom workflow activities for CRM 2011. There are lot of changes,  the way you write custom workflow code w.r.t CRM 2011. First thing, you need VS2010 on your system to start working with your project.
Choose a workflow activity library project on your VS 2010.
Add Microsoft.Xrm.sdk & Microsoft.Xrm.sdk.Workflow in your references to your project, when you add this, your project needs to be in .Net framework v 4.0.
Now comes the actual change !
Your workflow activity class needs to derive from a class named: CodeActivity ( a class present in System.Activities, remember to add this assembly in your project references and remove system.workflow.Activities from your directives else this will cause ambiguous error).
We have a new service which can be used for tracing your workflow code or plugin code, called ITracing service.  You can use this service to trace through your code at runtime, you can write messages to it.
You can see how to use this service at the below link:
 
Now coming back to our custom workflow code, there are changes in the way you declare your input & output properties. In CRM 4.0 we used to declare a dependency property for an input or output properties, but in CRM 2011 it’s as shown below:
[Input("Input Value")]
        [Default("Hello")] // this default value will be used if nothing you have specified in your input
        public InArgument<string> ServerName { get; set; }

        [Output("Output value")]
        public OutArgument<string> OutputValue { get; set; }

For more on how to declare your inputs & outputs, refer below link:
After this the usual, strong name your assembly & go on to register your workflow assembly using the new Plugin registration Tool for CRM 2011.
List of changes between CRM 4.0 custom workflow & CRM 2011 Custom workflow code is well explained in the below link:

Hope with this information you can go ahead and build custom workflow activities for CRM 2011.
Good Luck!!

No comments:

Post a Comment