我正在努力使用 CrmServiceClient 将属性值更新为 null。我的代码对于非空值工作正常,但因异常而失败:你调用的对象是空的。在 Microsoft.Xrm.Tooling.Connector.CrmServiceClient.AddValueToPropertyList(KeyValuePair 2
Field, AttributeCollection PropertyList) at
Microsoft.Xrm.Tooling.Connector.CrmServiceClient.UpdateEntity(String
entityName, String keyFieldName, Guid id, Dictionary2 fieldList, String applyToSolution, Boolean enabledDuplicateDetection, Guid batchId)每当我尝试设置空值时。到目前为止,我已经尝试了以下方法:// create Crm service client objectCrmServiceClient svc = new CrmServiceClient(new System.Net.NetworkCredential("username", "password", "domain"), "crmhost", "443", "crmorganization", false, true );// check the connection to CRM was successfulif (!svc.IsReady){ throw new Exception("Could not connect to CRM Organization.", svc.LastCrmException);}// create a Dictionary to store the attributes to be added to the entityDictionary<string, CrmDataTypeWrapper> attributes = new Dictionary<string, CrmDataTypeWrapper>();//this doesn't workattributes.Add("new_somedatefield", null);// and this doesn't workattributes.Add("new_somedatefield", new CrmDataTypeWrapper(null, CrmFieldType.CrmDateTime));// this also doesn't workDateTime? nullDate = new DateTime();nullDate = null;attributes.Add("new_somedatefield", new CrmDataTypeWrapper(nullDate, CrmFieldType.CrmDateTime));svc.UpdateEntity("new_entityname", "new_entitynameid", (Guid)data[metaData.PrimaryIdAttribute], attributes));文档中没有特别提到设置空值。有没有人成功地实现了这一目标?编辑 - 为了澄清我需要针对 Dynamics CRM 2015,CrmServiceClient 上的 Update 方法直到 2016 年才可用。
1 回答
- 1 回答
- 0 关注
- 167 浏览
添加回答
举报
0/150
提交
取消