09.11.2010, 19:05 | #1 |
Участник
|
Microsoft Dynamics CRM Team Blog: Custom workflow actions in Microsoft Dynamics CRM 2011 Online
Источник: http://blogs.msdn.com/b/crm/archive/...11-online.aspx
============== We have received multiple questions and feedback regarding the capability of adding custom workflow activities in CRM 2011 Online and I would like to provide some responses as well as offer some guidance on how to insert custom logic to workflows in CRM 2011 Online. Due to a technical limitation we are unable to support custom workflow activities in CRM 2011 Online. Custom workflow activities is a widely used feature and having direct support for it in Online is one of our top priorities, we are considering enabling this support in a future release. Nonetheless, this doesn’t mean that you cannot achieve having custom code that is executed as part of a workflow. There are multiple alternatives that make use of plugins combined with workflows to execute custom code asynchronously similar to custom workflow activities. I will explore one of these patterns in this article by using a real life scenario example. Scenario: My salespersons constantly call leads to offer our products. If the lead is interested we qualify the lead (convert to account) and add it to a marketing list for prospective buyers. Otherwise we disqualify the lead. We need a call script for the salespersons which seamlessly performs the lead qualification process in the background. Step 1: Identify which is the logic that is not supported by the CRM Workflow Designer and what inputs/outputs are required. The only part of my workflow that requires custom code is to add members to the marketing list. Everything else can be handled by configuring a dialog using the CRM workflow designer. For my custom code I don’t need any output but I will need two input parameters: The marketing list and the account which should be added to the list. Step 2: Create a custom entity to encapsulate the information from step 1. I will create a custom entity called “Add to marketing list action” hidden from the sitemap. To handle the inputs/outputs it will have two lookup attributes: A marketing list and an account. Step 3: Define the process in the workflow designer. I will define the dialog and for the custom action, I will insert a Create step for my custom entity. In the form I will configure the inputs using form assistant: Step 4: Write the custom code in a plugin I have my code which I will register in a sandboxed plugin which will trigger on create of “Add To Marketing List Action”. <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9D7513F9-C04C-4721-824A-2B34F0212519:ef7d9e5a-f348-4bb9-8cf6-cf6173c892f7" class="wlWriterSmartContent">publicsealedclass AddMemberToMarketingList : IPlugin{publicvoid Execute(IServiceProvider serviceProvider){IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext)); IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory) serviceProvider.GetService(typeof(IOrganizationServiceFactory)); IOrganizationService service = serviceFactory.CreateOrganizationService (context.UserId);Entity customEntity = (Entity)context.InputParameters["Target"]; AddMemberListRequest request =new AddMemberListRequest(); request.EntityId = ((EntityReference)customEntity["new_account"]).Id; request.ListId = ((EntityReference)customEntity["new_marketinglist"]).Id; service.Execute(request); }}
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору. |
|
Теги |
crm online, crm2011 |
|
|