[英]Update not working in SalesForce API
I'm trying to update a record via the SalesForce API (Enterprise WSDL). 我正在尝试通过SalesForce API(Enterprise WSDL)更新记录。
The code below executes fine, and the saveResult returned says that the operation was successful. 下面的代码执行正常,返回的saveResult表示操作成功。
Yet, when I look in SalesForce - the record has not been updated. 但是,当我查看SalesForce时-记录尚未更新。 The only thing that I can think of is that I am using the wrong Id - But I have quintuple checked this and checked it again and then re-checked it.
我唯一能想到的是我使用了错误的ID-但是我已经将五元组检查了一下,然后再次检查了一下,然后重新检查了一下。
Has anybody encountered something like this before? 有人遇到过这样的事情吗? Alternatively, I will be so pleased if someone can point out the stupid mistake that I've probably made somewhere :-)
另外,如果有人可以指出我可能在某个地方犯的愚蠢错误,我会很高兴的:-)
sforce.Participant__c updateParticipant = new sforce.Participant__c();
updateParticipant.Id = participant.Id.Length == 15? participant.Id : participant.Id.Substring(0, 15);
if (updateType == "pre")
{
updateParticipant.Manual_Download_Date__c = DateTime.Now;
updateParticipant.Manual_Download__c = true;
}
else if (updateType == "post")
{
updateParticipant.Post_Class_Manual_Download__c = true;
updateParticipant.Post_Class_Manual_Downloaded_Date__c = DateTime.Now;
}
sforce.SaveResult[] result = SFLib.sfdc.update(new sforce.sObject[] { updateParticipant });
if (result == null || result.Length <= 0)
return false;
else
{
if (result[0].success == true)
return true;
else
throw new Exception("Update participant failed", new Exception(result[0].errors[0].message));
}
When using .Net to call the Update method on the API, you need to set the *fieldname__cSpecified* field explicitly. 使用.Net调用API的Update方法时,需要显式设置* fieldname__cSpecified *字段。 Eg
例如
updateParticipant.aDateField_StartDate__c = DateTime.Now;
updateParticipant.aDateField_StartDate__cSpecified = true;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.