How to set Date fields in MSCRM 2011 Dialogs


If you are capturing a date in a dialog, it is not possible to assign that value to the crm datetime field. It can be done by creating workflow assembly.

Create a workflow assembly, which takes a string as input parameter and return date as output parameter. Here is code..

using System;
using System.Activities;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Workflow;

namespace DialogDate
{
public class DialogDate:CodeActivity
{
protected override void Execute(CodeActivityContext executionContext)
{

// Create the context
IWorkflowContext context = executionContext.GetExtension();
IOrganizationServiceFactory serviceFactory = executionContext.GetExtension();
IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);
string sdate = StringInput.Get(executionContext);
DateOutput.Set(executionContext,DateTime.Parse(sdate));

}

[Input(“string”)]
[Default(“10/11/2010”)]
public InArgument StringInput { get; set; }

[Output(“Date”)]
[Default(“01/01/01”)]
public OutArgument DateOutput { get; set; }

}
}

Register the assembly and use it in your dialog.

Call the assembly and pass the date string and use the return value to set the date field as shown in screen shots below.

Advertisements

About Dynamics CRM Guru

We are a group of CRM Consultants and have rich experience in all Microsoft CRM versions. Currently we provide training in Microsoft CRM 2015/CRM 2013 and CRM 2011.

Posted on July 27, 2011, in Microsoft CRM 2011, Microsoft Dynamics and tagged . Bookmark the permalink. 1 Comment.

  1. Hi, I do all this steps correctly, and I’ve the custom workflow correctly published. But i don’t know how to do this step: “Call the assembly and pass the date string and use the return value to set the date field as shown in screen shots below”.

    When I click in the “Set Properties” button of my custom workflow, i can’t choose anything. Operator Field is in blank, and if i select de date response of above and click the “add” button, nothing happens.

    I need some help please. ¿Can you describe this final step with more detail? thanks!

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: