更新没有在Salesforce的API工作 [英] Update not working in SalesForce API
问题描述
我想通过更新Salesforce的API(企业WSDL)的纪录。
下code执行的罚款,并在返回的saveResult说,手术很成功。
然而,当我看到在Salesforce - 记录尚未更新。我能想到的唯一的事情是,我使用了错误的ID - 但我已经五倍选中此并检查一遍,然后重新检查了
有没有人遇到过这样的事情过吗?或者,我会非常高兴,如果有人能指出愚蠢的错误,我可能做的地方: - )
sforce.Participant__c updateParticipant =新sforce.Participant__c(); updateParticipant.Id = participant.Id.Length == 15? participant.Id:participant.Id.Substring(0,15); 如果(UPDATETYPE ==pre)
{
updateParticipant.Manual_Download_Date__c = DateTime.Now;
updateParticipant.Manual_Download__c = TRUE;
}
否则,如果(UPDATETYPE ==邮报)
{
updateParticipant.Post_Class_Manual_Download__c = TRUE;
updateParticipant.Post_Class_Manual_Downloaded_Date__c = DateTime.Now;
} sforce.SaveResult []结果= SFLib.sfdc.update(新sforce.sObject [] {updateParticipant});
如果(结果== NULL || result.Length< = 0)
返回false;
其他
{
如果(结果[0] .success == true)而
返回true;
其他
抛出新的异常(更新参与者失败,新的异常(结果[0] .errors [0] .message));
}
在使用.NET来调用的API的更新方法,你需要明确设置* fieldname__cSpecified *领域。例如。
updateParticipant.aDateField_StartDate__c = DateTime.Now;
updateParticipant.aDateField_StartDate__cSpecified = TRUE;
I'm trying to update a record via the SalesForce API (Enterprise WSDL).
The code below executes fine, and the saveResult returned says that the operation was successful.
Yet, when I look in SalesForce - the record has not been updated. 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.
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. E.g.
updateParticipant.aDateField_StartDate__c = DateTime.Now;
updateParticipant.aDateField_StartDate__cSpecified = true;
这篇关于更新没有在Salesforce的API工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!