restforce gem save只改变了attriubtes?

时间:2017-10-31 13:48:58

标签: ruby-on-rails salesforce restforce

我在Ruby on Rails中使用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)

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

2 个答案:

答案 0 :(得分:0)

  

请检查此字段的安全设置,并验证您的个人资料或权限集是否已读/写。

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

答案 1 :(得分:0)

我能找到的唯一方法是使用find来代替使用find,我们将查询与我们想要更新的字段一起使用。

err_t recv_callback(void *arg, struct tcp_pcb *tpcb, struct pbuf *p, err_t err)
{
    for(j=0;j<count;j++)
    {
        // write buffer **MesStrBuf** for sending
        err = tcp_write(tpcb, MesStrBuf, sizeof(MesStrBuf), 1); 
        // prompt the system to send data now
        tcp_output(tpcb);
        tcp_poll(tpcb,poll_function,1);
    }
}
相关问题