更新不在SalesForce API中

Rob*_*obD 8 c# api salesforce

我正在尝试通过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));
        }
Run Code Online (Sandbox Code Playgroud)

Rob*_*obD 19

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

updateParticipant.aDateField_StartDate__c = DateTime.Now;
updateParticipant.aDateField_StartDate__cSpecified = true;
Run Code Online (Sandbox Code Playgroud)

  • 虽然这仅适用于某些类型,布尔/数字/日期,但它不适用于字符串. (2认同)
  • 我们花了好几个小时试图找出为什么我们的肥皂客户端无法将CaseComment.isPublished设置为true.谢谢@RobD.该文档位于SFDC肥皂API开发人员指南的"实施注意事项"页面底部http://www.salesforce.com/us/developer/docs/api/index_Left.htm#StartTopic=Content/implementation_considerations. HTM?检索类别=干 (2认同)