c# - 更新在 SalesForce API 中不起作用

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

最佳答案

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

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

关于c# - 更新在 SalesForce API 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9518268/

相关文章:

javascript - 使用 registerstartupscript 时出现意外标识符

ios - 在 iOS 上对 native 后台 API 调用使用react

php - 需要 Salesforce API 详细信息才能从我的网站 (PHP) 创建 salesforce CRM 中的潜在客户

salesforce - 用于发送电子邮件警报的 Apex 代码

javascript - 从表中删除行后,Visualforce 页面不刷新

c# - 可检查组合框的默认文本

c# - ~1 秒 TcpListener Pending()/AcceptTcpClient() 滞后

php - 使用 Twitter 单一访问 token 的 Zend OAuth

SalesForce:它可以显示外部页面/它可以发布到另一个 SF 实现吗

c# - 什么是 C# 静态字段命名约定?