restforce gem 只保存改变的属性?

restforce gem save only changed attriubtes?

我在 Rails Ruby 中使用 restforce 与 salesforce 进行交互。 我有这段代码:

client = Restforce.new
acc = client.find("Account", account_ID)
acc.firstName = "test"
acc.save
# if I use update I get the same error
acc.update

但是我得到以下错误

[
    {
        "message":"Unable to create/update fields: jigsaw_clean__Sync_Status_Indicator__c, LastModifiedDate, PhotoUrl, IsDeleted, jigsaw_clean__Jigsaw_Managed_Backend__c, jigsaw_clean__Sync_Status_Summary__c, AccPwr1__c, BillingAddress, jigsaw_clean__Duplicate__c, LastActivityDate, jigsaw_clean__Automatic_Updates__c, JigsawCompanyId, CreatedById, MasterRecordId, LastViewedDate, CreatedDate, LastReferencedDate, jigsaw_clean__Additional_Information__c, jigsaw_clean__Jigsaw_Last_Sync_Locked__c, Cross_Sell_Score__c, jigsaw_clean__Jigsaw_Managed__c, ShippingAddress, LastModifiedById, IANA_Number_field__c. Please check the security settings of this field and verify that it is read/write for your profile or permission set.",
        "errorCode":"INVALID_FIELD_FOR_INSERT_UPDATE",
        "fields":[
            "jigsaw_clean__Sync_Status_Indicator__c",
            "jigsaw_clean__Jigsaw_Managed_Backend__c",
            "jigsaw_clean__Sync_Status_Summary__c",
            "AccPwr1__c",
            "BillingAddress",
            "jigsaw_clean__Duplicate__c",
            "LastActivityDate",
            "jigsaw_clean__Automatic_Updates__c",
            "CreatedById",
            "MasterRecordId",
            "jigsaw_clean__Additional_Information__c",
            "jigsaw_clean__Jigsaw_Last_Sync_Locked__c",
            "Cross_Sell_Score__c",
            "jigsaw_clean__Jigsaw_Managed__c",
            ]
    }
] 

等领域。

我知道,我可以这样做:

client = Restforce.new
acc = client.find("Account", account_ID)
acc1 = {Id: acc.Id}
acc1["firstName"] = "test"
client.update("Account", acc1)

如何以更有效的方式执行此操作?

Please check the security settings of this field and verify that it is read/write for your profile or permission set.

您确定您有权进行更新吗?

我能找到的唯一方法是不使用查找,而是使用包含我们要更新的字段的查询。

client = Restforce.new
acc1 = client.query("SELECT ID, firstName, LastName FROM Account where ID = '#{account_ID}'").first
acc1["firstName"] = "test"
acc1.save