MS CRM Notes

December 24, 2011

FetchXML Builder

Plugin Developer

writing Workflows

Form Builder

Different Views:

Form View

Advanced Find

Lookup Views

Quick View

Associated View

On Demand Workflow

Manual workflow

On REcord is Created/deleted

Record status change

Record is assigned

Record field is changed

Status and Status Reason Values for Select Entities

Entity Status values Status Reason values

Account    Active Inactive                         Active Inactive

Case           Active Resolved  Canceled          In Progress On Hold  Waiting for Details Researching Problem Solved Canceled

Lead        Open  Qualified Disqualified         New Contacted Qualified  Lost  Cannot Contact  No Longer Interested Canceled

System Jobs to monitor

Workflow step editor  : define steps in workflow


Code :

using System;
using System.IO;
using System.Net;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Collections;
using System.Workflow.ComponentModel.Compiler;
using System.Workflow.ComponentModel.Serialization;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Design;
using System.Workflow.Runtime;
using System.Workflow.Activities;
using System.Workflow.Activities.Rules;
using Microsoft.Crm.Sdk;
using Microsoft.Crm.SdkTypeProxy;

using Microsoft.Crm.Workflow;
using Microsoft.Crm.Workflow.Activities;
using Microsoft.Crm.Sdk.Query;

namespace Updatingincident
[CrmWorkflowActivity(“updating incident”, “cal”)]

public partial class calculate : SequenceActivity
protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)

IContextService contextService = (IContextService)executionContext.GetService(typeof(IContextService));
IWorkflowContext context = contextService.Context;

ICrmService crmService = context.CreateCrmService();

WhoAmIRequest systemUserRequest = new WhoAmIRequest();
WhoAmIResponse systemUser = (WhoAmIResponse)crmService.Execute(systemUserRequest);

// using the GUID of current case

ColumnSet cols = new ColumnSet();
Guid guidID = new Guid(this.objectID.Value.ToString());

incident ret = (incident)crmService.Retrieve(EntityName.incident.ToString(), guidID, new AllColumns());

DateTime a = DateTime.Parse(;

DateTime b = DateTime.Parse(;

TimeSpan tid = b – a;

CrmNumber tes = new CrmNumber();
tes.Value = tid.Days;
// i will use existing field on CRM incident to hold the integer value.

ret.actualserviceunits = tes;

// updating the case entity

return ActivityExecutionStatus.Closed;

// getting the id of case

public static DependencyProperty objectIDProperty = DependencyProperty.Register(“objectID”, typeof(Lookup), typeof(calculate));

[CrmInput(” objectID”)]
public Lookup objectID
return (Lookup)base.GetValue(objectIDProperty);
base.SetValue(objectIDProperty, value);


// start date as input parameter

public static DependencyProperty startdateProperty = DependencyProperty.Register(“startdate”, typeof(CrmDateTime), typeof(calculate));

[CrmInput(” startdate”)]

public CrmDateTime startdate
return (CrmDateTime)base.GetValue(startdateProperty);
base.SetValue(startdateProperty, value);

// End date as input parameter

public static DependencyProperty enddateProperty = DependencyProperty.Register(“enddate”, typeof(CrmDateTime), typeof(calculate));

[CrmInput(” enddate”)]

public CrmDateTime enddate
return (CrmDateTime)base.GetValue(enddateProperty);
base.SetValue(enddateProperty, value);


Register the assembly

Now we need to register the Custom assembly as pulgin . I would be using plugin developer to register this assembly.

In MS CRM for a task go to workflows -> Add Step Conditio-> WorkflowUtilities


Add Step choices available  to you with the workflow editor:

Check conditions

 Wait conditions

 Workflow actions