我正在按照this指南将DateTime字段更新为Dynamics中的日期字段。当我在下面运行我的代码时,我没有收到错误,但我也没有看到我的日期字段有任何更改。如何将DynamicsTime中的DateTime字段转换为日期?
更新:基于帕维尔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);
}
}
}
原来是忘记发布我的更改后,我已经使他们 –