Workflow ActivityCustom Workflow Activity for matching email addresses to customers – Microsoft Dynamics 3. Team blog. In an earlier blog (E- mail to Case/Lead Using CRM 4 Workflow ), I described a sample workflow that could be used to automatically create cases based on emails sent to a queue. One of the questions that was frequently asked for the above blog was that the email activity’s regarding field set to blank. ![]() Dynamics Crm Custom Workflow![]() A simple custom workflow activities to add/remove user to the access team. · When working with Microsoft Dynamics CRM, one of the most common tasks undertaken is to m ap real life business processes and to automate these within CRM. With Polaris it is now possible to register Custom workflow assembly for CRM Online as well. In continuation of our earlier series here where we provided the. · We currently support lengthy CRM operations, up to 30 minutes, using custom code workflows in our on-premise deployments. We haven't been able to register. · . (online), Dynamics 365 (on-premises), Dynamics CRM 2016, Dynamics CRM Online. The custom workflow activity can then be incorporated into a workflow. In this blog, I’ll show how this can be done using a custom CRM workflow activity. Let’s summarize the problem we are trying to solve. Joe (joe@mycustomer. Joe sends an email to your support alias to report an issue. We would like the email activity that is created to be regarding Joe’s account. For those of you new to writing custom workflow activities, I highly recommend that you take a look at the SDK documentation at: http: //msdn. It contains all the information needed for you to start using custom workflow activities. · The following are the steps we have to follow in order to debug a custom workflow activity in Dynamics CRM: Step 1. Run the Plugin Registration Tool as an. I’m going to split my solution into 2 parts: 1) A custom workflow activity that takes an email address as input and returns a matching account as output 2) A workflow rule that uses the above custom activity. This workflow rule is triggered when an email is created and updates the email activity to have the regarding field set to the output returned by the custom workflow activity. Custom Workflow Activity. Let’s walk thru’ the code for the custom workflow activity. Define the class skeleton and the using statements for the various namespaces that we will need. Please ensure you have read and understood the SDK documentation at: http: //msdn. CRM custom workflow activities. This project includes custom workflow activities for Microsoft Dynamics CRM which provide additional workflow steps for actions such as "delete" and "share". · Sending WebHooks with Microsoft Dynamics CRM. The source for the custom workflow activity for CRM that we’ve developed above is available here. System. Workflow. Activities; using System. Workflow. Component. Model; using Microsoft. Crm. Sdk; using Microsoft. Crm. Sdk. Type. Proxy; using Microsoft. Crm. Workflow; using Microsoft. Crm. Sdk. Query; namespace Crm. Custom. WFActivity{ [Crm. Workflow. Activity("Find Customer with specified email address")] public class Match. Sender. With. Existing. Customer. Activity: System. Workflow. Activities. Sequence. Activity { // Activity code goes here. }}2) Now, add properties that represent the inputs and outputs. As discussed earlier, the input is an email address (of type string) and the output will be the matching account (of type Lookup). Dependency. Property is a Windows Workflow concept and you can read more about it here: http: //msdn. Input property 2: publicstatic Dependency. Property sender. Property = Dependency. Property. Register("sender", typeof(string), typeof(Match. Sender. With. Existing. Customer. Activity)); 3: 4: [Crm. Input("Sender")] 5: publicstring sender 6: { 7: get 8: { 9: return (string)base. Get. Value(sender. Property); 1. 0: } 1. Set. Value(sender. Property, value); 1. Output property 1. Dependency. Property account. Id. Property = Dependency. Property. Register("account. Id", typeof(Lookup), typeof(Match. Sender. With. Existing. Customer. Activity)); 2. Crm. Output("Account. Id")] 2. 2: [Crm. Reference. Target("account")] 2. Lookup account. Id 2. Lookup)base. Get. Value(account. Id. Property); 2. 8: } 2. Set. Value(account. Id. Property, value); 3. This custom workflow activity needs to be able to retrieve accounts whose email address matches the sender property value. To do this, it needs to be able to call into CRM SDK methods and can do this thru’ Icrm. Service interface that is provided to all crm custom workflow activities. The following is code for a helper method that uses CRM query functionality to return account that matches the email address. Guid Match. Sender. With. Existing. Account(ICrm. Service crm. Service, string from. Address) 2: { 3: // Retrieve accounts with this email address. Query. By. Attribute query = new Query. By. Attribute(); 5: query. Entity. Name = Entity. Name. account. To. String(); 6: query. Attributes = newstring[] { "emailaddress. Values = newstring[] { from. Address }; 8: 9: Retrieve. Multiple. Request retrieve. Multiple. Request = new Retrieve. Multiple. Request(); 1. Multiple. Request. Query = query; 1. Multiple. Request. Return. Dynamic. Entities = true; 1. Retrieve. Multiple. Response retrieve. Multiple. Response = (Retrieve. Multiple. Response)crm. Service. Execute(retrieve. Multiple. Request); 1. Guid account. Id = Guid. Empty; 1. 8: 1. Business. Entity bus. Entity in retrieve. Multiple. Response. Business. Entity. Collection. Business. Entities) 2. 0: { 2. Pick the first accountid. Id = ((Key)(((Dynamic. Entity)bus. Entity)["accountid"])). Value; 2. 3: break; 2. Id; 2. 7: }4) Now, we can implement the Execute method of the custom workflow activity. System. Workflow. Component. Model. Activity. Execution. Status Execute(System. Workflow. Component. Model. Activity. Execution. Context execution. Context) 2: { 3: IContext. Service context. Service = (IContext. Service)execution. Context. Get. Service(typeof(IContext. Service)); 4: IWorkflow. Context context = context. Service. Context; 5: 6: // Obtain Icrm. Service so we can call into CRM SDK to retrieve 7: // accounts 8: ICrm. Service crm. Service = context. Create. Crm. Service(); 9: 1. Guid account. Id = Match. Sender. With. Existing. Account(crm. Service, this. Set the account. Id output property to return this data 1. Id = new Lookup("account", account. Id); 1. 6: 1. 7: return Activity. Execution. Status. Closed; 1. 8: } 1. Id; Using The Custom Workflow Activity. In order to use Match. Sender. With. Existing. Customer. Activity in workflow rules, you need to register the activity. Follow the steps at: http: //msdn. We will create a workflow rule that does the following: 1) When an email is created, it checks if the email’s regarding field is set. If not set, it invokes Match. Sender. With. Existing. Customer. Activity 3) It updates email with the accountid returned by Match. Sender. With. Existing. Customer. Activity. Let’s walk through these in more detail. Create the workflow rule, call it Set. Email. Regarding and set it to trigger on email create 2) Insert a check condition step and configure it to check if Email: regarding field does not contain data 3) If Email: regarding is not set, we want to invoke the Match. Sender. With. Existing. Customer. Activity. Under the add step drop- down, you should find the custom workflow activity as shown below: 4) After you select Match. Sender. With. Existing. Customer. Activity, you need to ensure that it is being invoked with the correct input. Click ‘Set Properties’ and set the value of the input parameter Sender to that of Email: Sender 5) The next step would be to update the email’s regarding to the value returned by the custom workflow activity in the previous step. To do this, add a Update Email step, select ‘Set Properties’ and tab to the ‘Regarding’ field. In the dynamic values form assistant, you will now find that it shows ‘Match email address: accountid’ to indicate the return value from the previous step. Select this to be the value for regarding field as shown below. Publish the workflow and verify that it is working. Since the functionality to match email address to an account has been captured as a custom workflow activity, you will be able to use that activity in all your workflow rules. You can also enhance the custom workflow activity by making it return either a matching account or contact if needed. If you need to create an account/contact if a match wasn’t found, you can do this by adding a Create step to the workflow rule.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |