【发布时间】:2017-04-24 19:45:14
【问题描述】:
我正在按照 this 指南将 DateTime 字段更新为 Dynamics 中的 Date 字段。当我在下面运行我的代码时,我没有收到错误,但我也没有看到我的日期字段有任何更改。
更新:根据 Pawel Gradecki 的回答和 this 文章,我检查了 AsyncOperationBase 表,发现以下消息似乎与实体定义相矛盾(如屏幕截图所示)。
参数转换规则:SpecificTimeZone TimeZoneCode:35 自动转换:错误错误详细信息:指定的属性不是日期 和具有仅日期行为的时间属性:实体: ccseq_clientstatus,属性:ccseq_prospectstatusdate 属性 处理完毕
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Client;
using Microsoft.Xrm.Sdk.Messages;
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
namespace UpdateDateClientStatus1
{
class Program
{
static void Main(string[] args)
{
var cred = new System.ServiceModel.Description.ClientCredentials();
cred.Windows.ClientCredential.Domain = "DOMAIN";
cred.Windows.ClientCredential.UserName = "USERNAME";
cred.Windows.ClientCredential.Password = "PASSWORD";
OrganizationServiceProxy _serviceProxy = new OrganizationServiceProxy(new Uri("url"), null, cred,null);
ConvertDateAndTimeBehaviorRequest request = new ConvertDateAndTimeBehaviorRequest()
{
Attributes = new EntityAttributeCollection()
{
// ccseq_clientstatus is the entity I am updating and ccseq_prospectstatusdate is the field I am updating
new KeyValuePair<string, StringCollection>("ccseq_clientstatus", new StringCollection()
{ "ccseq_prospectstatusdate" })
},
ConversionRule = DateTimeBehaviorConversionRule.SpecificTimeZone.Value,
TimeZoneCode = 035,// Time zone code for EST in CRM
AutoConvert = false // Conversion must be done using ConversionRule
};
// Execute the request
ConvertDateAndTimeBehaviorResponse response = (ConvertDateAndTimeBehaviorResponse)_serviceProxy.Execute(request);
}
}
}
【问题讨论】:
-
原来是在我做出更改后忘记发布我的更改
标签: c# datetime dynamics-crm