16 June 2010

SQL divide by zero "isZero" function

Recently come across a requirement on SQL to divide 2 columns and populate in a custom fields. Infact is just something simple like "SELECT column1/column2 AS result"


Issue raised because the "column2" might contains zero or null value, what we need to do is if column 2 is zero replace it with another fix non zero varible.
  • Null issue can be easily solve by using isNull finction, but we don't have 'isZero' function
The solution is to use the nullif function with isnull function;
set column2 to null value if it is zero, outer level if is null replace with variable X.
ISNULL(NULLIF(column2, 0),variableX)

CRM 4.0 Update Rollup 11

Latest CRM 4.0 rollup 10 released on 3/June/2010.
Rollup 11 can be uninstall on server
Rollup 11 is cumulative.
Rollup 1,2,3,4,5,6,7,8,9,10 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:


KB:
KB981328
Download
HERE

15 June 2010

CRM 4 Build Number - Version

VersionBuild NumberRelease onLink ID(en)Patch ID(en)
RTM4.0.7333.312/19/2007
Rollup 14.0.7333.111311/24/2008
Rollup 24.0.7333.1312, 4.0.7333.13161/15/2009, 2/8/2009
Rollup 34.0.7333.14083/12/2009
Rollup 44.0.7333.15515/7/2009150735&clcid=0x409{004A7E60-5DB7-4F05-B7C1-1D2DD653A1A6}
Rollup 54.0.7333.1644, 4.0.7333.16457/2/2009157191&clcid=0x409{592DDF5E-D0D7-46FE-81C3-A3BCAC5E8F22}
Rollup 64.0.7333.17509/27/2009162439&clcid=0x40{7E83D1E5-7B7A-45D1-8930-4FEFB4123B57}
Rollup 74.0.7333.213810/22/2009167830&clcid=0x409{657DF4CA-4167-48C2-937E-1B4940C0F3C9}
Rollup 84.0.7333.254212/17/2009179669&clcid=0x409{7D1C2874-9093-4563-83C6-C2F82C8D82B8}
Rollup 94.0.7333.264402/11/2010181054&clcid=0x409{45859F4D-AC35-4FB3-A474-40492079C74A}
Rollup 104.00.7333.27414/8/2010184388&clcid=0x409{C853A15A-5546-4F07-BF41-FC1C64570AB3}
Rollup 114.0.7333.28616/3/2010192046&clcid=0x409{77F3EBA0-20E8-403E-B43B-E5AC633E139E}
Rollup 124.0.7333.29357/30/2010194246&clcid=0x409 {99DA550E-457E-4339-A520-414AC14AE82C}
Rollup 134.0.7333.30189/23/2010199444&clcid=0x409{414017EA-201F-401D-BD4D-FDB8C2FD5AC8}
Rollup 144.00.7333.313511/18/2010202910&clcid=0x409{3A11783F-F1EF-431C-AB61-0B165502DBF0}
Rollup 154.00.7333.32311/10/2010206903&clcid=0x409{89833E9D-C22F-4EB9-A76F-A84623D67613}
Rollup 164.00.7333.33353/10/2011209024&clcid=0x409 {6EA3A2FA-08DF-40B5-842B-1C6B6EC6B028}
Rollup 174.00.7333.34145/5/2011214427&clcid=0x409 8{87297B34-767B-4E3B-A51B-C89DB849AE82}
Rollup 184.00.7333.35316/30/2011218855&clcid=0x409{E054D596-F999-4BB2-9130-662E11CC26FF}
Rollup 194.00.7333.36288/25/2011224158&clcid=0x409{2DEE4EFD-B1CF-49CA-A37E-DD9BE6C8E2B7}
Rollup 204.00.7333.373211/10/2011227975&clcid=0x409{A4CEC8ED-18B4-4682-9D4D-1BD0C4FC85AC}

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);
    }
   }