11 April 2010

CRM 4.0 Update Rollup 10

Latest CRM 4.0 rollup 10 released on 8/April/2010.
Rollup 10 can be uninstall on server
Rollup 10 is cumulative.
Rollup 1,2,3,4,5,6,7,8,9 are not prerequisites for server portion.
Update Rollup 7 is a prerequisite for Microsoft Dynamics CRM for Microsoft Office Outlook and Microsoft Dynamics CRM Data Migration Manager.

Special Considerations:

  1. 64-bit versions of Office 2010 will not be supported in Microsoft Dynamics CRM 4.0.
  2. With Update Rollup 8 installed, Microsoft CRM E-mail Router Service supports Microsoft Exchange 2010. However, because of an issue with MAPI, the Rule Deployment Wizard does not support Microsoft Exchange 2010. This issue will be addressed in a future update of Microsoft Exchange 2010.


KB:
KB979347
Download
HERE

09 April 2010

Stop previous workflow instance.

Recently come across a business scenario where a workflow needs to be run after record being assign to others. The problem is workflow configured as wait after 1 hour, then update a field.


It is possible that during the 1 hour waiting time, user might reassign again~~again, result of that is multiple same workflow actually is running and waiting at the same time...what we want is just the running the latest workflow instance only.


To solve this problem, create a CRM 4 plugin to query related workflow with specific workflow name, check its status then update it to cancelled.


Register as pre-stage; synchronous, so that it won't cancelled the latest workflow instance .


string error = string.Empty;

   ColumnSet colsWf = new ColumnSet(new string[] { "name", "statuscode", "asyncoperationid", "regardingobjectid" });

   ConditionExpression conditionName = new ConditionExpression("name", ConditionOperator.Equal, workflowName);
   ConditionExpression conditionRegardingObjectId = new ConditionExpression("regardingobjectid", ConditionOperator.Equal, recordId);

   FilterExpression filter = new FilterExpression();
   filter.FilterOperator = LogicalOperator.And;
   filter.AddCondition(conditionName);
   filter.AddCondition(conditionRegardingObjectId);

   QueryExpression query = new QueryExpression(EntityName.asyncoperation.ToString());
   query.Criteria = filter;
   query.ColumnSet = colsWf;

   BusinessEntityCollection results = service.RetrieveMultiple(query);
   if (results.BusinessEntities.Count > 0)
   {
    for (int i = 0; i < results.BusinessEntities.Count; i++)
    {
     asyncoperation singleWorkflowInstance = (asyncoperation)results.BusinessEntities[i];
     if (singleWorkflowInstance.statuscode.Value == AsyncOperationStatus.WaitingForResources || singleWorkflowInstance.statuscode.Value == AsyncOperationStatus.Waiting || singleWorkflowInstance.statuscode.Value == AsyncOperationStatus.InProgress || singleWorkflowInstance.statuscode.Value == AsyncOperationStatus.Pausing)
     {
      try
      {
       Status statusCanceled = new Status();
       statusCanceled.Value = AsyncOperationStatus.Canceled;

       AsyncOperationStateInfo state = new AsyncOperationStateInfo();
       state.Value = AsyncOperationState.Completed;

       SetStateWorkflowRequest request = new SetStateWorkflowRequest();
       singleWorkflowInstance.statuscode = statusCanceled;
       singleWorkflowInstance.statecode = state;

       TargetUpdateAsyncOperation operation = new TargetUpdateAsyncOperation();
       operation.AsyncOperation = singleWorkflowInstance;

       UpdateRequest update = new UpdateRequest();
       update.Target = operation;
       UpdateResponse updated = (UpdateResponse)service.Execute(update);
      }
      catch (System.Web.Services.Protocols.SoapException ex)
      {
       error = "KillWorkflow Error " + ex.Message + "" + ex.StackTrace;
      }
      catch (Exception ex)
      {
       error = "KillWorkflow Error " + ex.Message + "" + ex.StackTrace;
      }
     }
    }
    if (!string.IsNullOrEmpty(error))
    {
     throw new Exception(error);
    }
   }

08 April 2010

CRM 4.0 Update Rollup 9

Latest CRM 4.0 rollup 9 released on 11/2/2010.
Rollup 9 can be uninstall on server
Rollup 9 is cumulative.
Rollup 1,2,3,4,5,6,7,8 are not prerequisites for server portion.
Update Rollup 7 is a prerequisite for Microsoft Dynamics CRM for Microsoft Office Outlook and Microsoft Dynamics CRM Data Migration Manager.

KB:
KB977650
Download
HERE