Sunday, July 18, 2010

MS CRM Social Networking Workflow DateTime Format Error.

The accelerator code as supplied does not correctly parse Twitter timestamps. DateTime.ParseExact breaks on the odd time zone value, which in (GMT/UK) comes from twitter with the value "+0000".

DateTime.ParseExact can use a format string of "z", "zz", or "zzz", corresponding to "+0", "+00" or "+00:00" respectively, none of which match the Twitter format.

You need to change the code in teh BuildDynEntity() method, in msa_datapump.cs, as follows:

case "CrmDateTimeProperty":
//Twitter timestamps contain odd timezone specifier "+0000" that doesn;t work
// well with DateTime.ParseExact().
CrmDateTimeProperty crmDateTimeProperty = new CrmDateTimeProperty();
CrmDateTime crmDateTimeValue = new CrmDateTime();
DateTimeOffset parsedDateTime = DateTimeOffset.ParseExact(CRMAttrValue, "ddd MMM dd HH:mm:ss zzz yyyy", null);
DateTime localDateTime = new DateTime(parsedDateTime.Ticks, DateTimeKind.Local);
crmDateTimeProperty.Value = CrmDateTime.FromUser(localDateTime);
crmDateTimeProperty.Name = CRMAttrName;

Save / Complile / Build the assembly.

Register the assembly using plug-in registration tool.
Restart the Microsoft Crm Async Service.

Start Creating the Twitter User. Now the workflow won't failed (i mean it will not be on the Waiting state anymore !!!).

Hope this will resolves the issue.

No comments: