Posts

Showing posts from June, 2014
Workflow solution creation , registration and usage in CRM2011 In this blog I would like to explain some practical steps about the Workflow lifecycle in CRM 2011. The steps includes  1. Creation of the workflow solution ( C# solution ) and generation of the assembly  2. Registering the workflow assembly for CRM usage 3. Using the workflow assembly in CRM  1. Creation of the workflow solution and generation of the assembly  The workflow can be defined as group of activities that performs the required process.+ a) Creating the activities of the Workflow steps in the C# solution   Workflow activities are defined in the System.Activities.dll of .NETFramework, so we need to add this dll to the workflow solution. Define the Class :  The workflow activities that are used in CRM are derived from the "CodeActivity" base class.  so define the workflow activity class derived from the "CodeActivity" class.      eg : public class Sampleworkflow : CodeActivity {}   O
Associate two records using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Activities; using Microsoft.Xrm.Sdk; using Microsoft.Xrm.Sdk.Workflow; using Microsoft.Xrm.Sdk.Messages; using Microsoft.Xrm.Sdk.Query; using Microsoft.Crm.Sdk.Messages; using Microsoft.Xrm.Sdk.Metadata; namespace AssociatedLeadEmail_WF {     public class AssociatedLeadEmail_WF : CodeActivity     {         #region Set the input mandatory parameters.         //Input Value of Associated Lead Record         [RequiredArgument]         [Input("Email Send")]         [ReferenceTarget("cdi_emailsend")]         public InArgument<EntityReference> EmailSend { get; set; }         [RequiredArgument]         [Input("Lead")]         [ReferenceTarget("lead")]         public InArgument<EntityReference> Lead { get; set; }         [Output("Success")]         public OutArgument<bool>
Send Template Email The Send Template Email custom workflow activity will search for Template Records where the Lead Source and Lead Sub-Source are match the Source and Sub-Source from the designated lead, or are null. Using the email template specified on the Template Record, the custom workflow activity will create an email from the template and send it to the lead using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Activities; using Microsoft.Xrm.Sdk; using Microsoft.Xrm.Sdk.Workflow; using Microsoft.Xrm.Sdk.Messages; using Microsoft.Xrm.Sdk.Query; using Microsoft.Crm.Sdk.Messages; using Microsoft.Xrm.Sdk.Metadata; namespace LeadTemplate_WF {     public class LeadTemplate_WF : CodeActivity     {         #region Set the input mandatory parameters.         //Input Value of Template Record         [RequiredArgument]         [Input("new_leadorigin")]         [ReferenceTarget("sbi_leadorigin")]
Ribbon and UI Customizations Email Template Selector On the form ribbon of the Template Record add a flyout to display a list of Email Templates for leads. On click of a button in the flyout, set the Template field to the id of the specified Email Template. The flyout should be enabled only for existing, editable records. Code: /************************************************ populateArticles - function to populate a button on the ribbon with the available disclaimers Policy is 1 ************************************************/ function PopulateArticles1(CommandProperties) {     var serverUrl = Xrm.Page.context.getClientUrl();     var requestUrl = serverUrl + "/xrmservices/2011/OrganizationData.svc/cdi_emailtemplateSet?$select=cdi_emailtemplateId,cdi_name&$filter=statecode/Value eq 0";          $.ajax({         type: "GET",         contentType: "application/json; charset=utf-8",         datatype: "json&qu