更新在SalesForce API中无效

本文关键字:无效 API SalesForce 更新 | 更新日期: 2023-09-27 18:26:24

我正在尝试通过SalesForce API(企业WSDL)更新记录。

下面的代码执行良好,返回的saveResult表示操作成功。

然而,当我查看SalesForce时,该记录尚未更新。我唯一能想到的是我使用了错误的Id-但我已经检查了五次,再次检查,然后再次检查。

以前有人遇到过这样的事情吗?或者,如果有人能指出我可能在某个地方犯的愚蠢错误,我会很高兴:-)

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));
        }

更新在SalesForce API中无效

使用.Net在API上调用Update方法时,需要显式设置*fieldname__cSpecified*字段。例如

updateParticipant.aDateField_StartDate__c = DateTime.Now;
updateParticipant.aDateField_StartDate__cSpecified = true;