|
18.11.2010, 01:12 | #1 |
Участник
|
Microsoft Dynamics CRM Team Blog: Upgrading a CRM 4.0 Custom Workflow Activity to CRM 2011
Источник: http://blogs.msdn.com/b/crm/archive/...-crm-2011.aspx
============== CRM MVP Mitch Milam is our guest blogger today. Read Mitch’s blog. I recently upgraded one of my custom workflow activity plugins to CRM 2011 and thought it would be an interesting exercise to walk through that process with you. So let’s walk through the changes, from top to bottom. Reference Assemblies As with any application that communicates with CRM, you need to reference the CRM SDK assemblies: CRM 4.0 using System.Workflow.Activities;CRM 2011 using System.Activities;Creating Parameters for the Activity This activity accepts 4 parameters, one of which was required. In this example, we are:
With CRM 4.0 developers were generally targeting the .NET Framework v3.0 (or3.5), so to define an input parameter looked something like this: public static DependencyProperty MarketingListLookupProperty = DependencyProperty.Register("MarketingListLookup", typeof(Lookup), typeof(RemoveFromMarketingList)); [CrmInput("Marketing List")] [ValidationOption(ValidationOption.Required)] [CrmReferenceTarget("list")] public Lookup MarketingListLookup { get { return (Lookup)base.GetValue(MarketingListLookupProperty); } set { base.SetValue(MarketingListLookupProperty, value); } } In the .NET Framework 4.0, the parameter definition is slightly condensed: [Input("Marketing List")] [ReferenceTarget("list")] [RequiredArgument] public InArgument MarketingListEntityReference { get; set; } The class definition has changed slightly due to the change in Windows Workflow versions. Beside the base class changing from SequenceActivity to CodeActivity, you will notice the CRM 2011 version does not have the “decorations” that specify the group and name that will be displayed within the CRM workflow editor. More on that later. CRM 4.0 [CrmWorkflowActivity("Remove from Marketing List", "CRM Accelerators")]CRM 2011 public class AddToMarketingList : CodeActivityExecute Method The Execute method remains the sole method required for a custom workflow activity though the Context parameter and return value have changed. CRM 4.0 protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)CRM 2011 protected override void Execute(CodeActivityContext executionContext)Connecting to CRM The code that defines the connection to the CrmService has changed slightly as well, but overall, the concepts remain the same:
IContextService contextService = (IContextService)executionContext.GetService(typeof(IContextService));CRM 2011 IWorkflowContext context = executionContext.GetExtension();Accessing Parameter Values Accessing the values found within the input parameters is slightly different in CRM 2011 where the value of the parameter is not actually extracted until you actually need to use it. In CRM 4.0, that process happens more or less automatically due to the DependencyProperty setup. CRM 4.0 Guid ListId = MarketingListLookup.Value;CRM 2011 Guid ListId = MarketingListEntityReference.Get(executionContext).Id;Doing the Work After you have all of the above code in place, the remainder of your code should function as it did in CRM 4.0. I did not have to make any changes to my code once the “plumbing” was upgraded. Registering your Plugin The registration process is exactly the same between versions: You use the Plugin Registration Tool. The biggest difference between the two is in CRM 2011, the Plugin Registration Tool is where you specify how the custom workflow activity is displayed to the user within the workflow editor. When you highlight the workflow activity, you need to specify the FriendlyName, Name, and WorkflowActivityGroupName properties as shown below: Note: Even though the above figure doesn’t show it, the FriendlyName and Name properties need to be the same. Conclusion Well, that is about it. It probably only took me 2 hours to perform the upgrade of my code and that was starting from scratch with zero knowledge of the process. I just reviewed the SDK documentation and sample code and worked through each issue as it was encountered. I hope this helps and good luck. Mitch Milam Источник: http://blogs.msdn.com/b/crm/archive/...-crm-2011.aspx
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору. |
|
Теги |
crm online, crm2011 |
|
Опции темы | Поиск в этой теме |
Опции просмотра | |
|