Tuesday, November 03, 2009

Custom workflow action which returns current DateTime value

Here is the code:

using System;
using System.Collections.Generic;
using System.Text;
using System.Workflow.Activities;
using Microsoft.Crm.Workflow;
using System.Workflow.ComponentModel;
using Microsoft.Crm.Sdk;
using Microsoft.Crm.Sdk.Query;
using Microsoft.Crm.SdkTypeProxy;

namespace CurrentDateTimeWorkflowStep
{
[CrmWorkflowActivity("Current Date Time", "Utiles")]
public class CurrentDateTime : SequenceActivity
{
protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
{
Value = CrmDateTime.Now;

return base.Execute(executionContext);
}

public static DependencyProperty ValueProperty = DependencyProperty.Register("Value", typeof(CrmDateTime), typeof(CurrentDateTime));

[CrmOutput("Value")]
public CrmDateTime Value
{
get
{
return (CrmDateTime)base.GetValue(ValueProperty);
}
set
{
base.SetValue(ValueProperty, value);
}
}
}
}


And here is the source project and built assembly.

1 comment:

  1. I have downloaded and registered this but I am not sure how to use it. Do you have a screen shot I could look at?

    I want to use it in a wait condition that waits until the due date equals the system date/time.

    ReplyDelete