New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Updating sObject from getRecord method forces update of all fields not fields set #68
Comments
Looking at the documents more, the info in your docs is not consistent. For example Querying and updating records is super easy. nforce wraps API-queried records in a special object. The object caches field updates that you make to the record and allows you to pass the record directly into the update method without having to scrub out the unchanged fields. In the example below, only the Name and Industry fields will be sent in the update call despite the fact that the query returned other fields such as BillingCity and CreatedDate. So it seems this is actually a bug. Because getRecord does not behave like query |
I can take a look at this tomorrow. It's likely a bug from the refactor to the 0.8 beta. On Thu, Oct 2, 2014 at 9:32 PM, Patrick Hogan notifications@github.com
|
This was indeed a bug from the refactor to 0.8. This actually effects query too. What was happening was the initialization of a new SObject was setting all of the fields to changed status as that's the normal behavior when a user creates a new SObject. There was a You'll see this in 0.9.0 tonight. |
0.9.0 is now available |
I experienced a strange workflow issue today when reading the documentation to nforce and the expected result I got. I can see now after digging into code and setting breakpoints what occurred and why, I am just hoping the maintainers will edit the README to spell out potential problems for users.
My use case was that I was trying to update a salesforce record. I read the update method and found out it required an sObject. I have a method that uses the getRecord method and returns an sObject and then calls another function. With the other function I set three parameters and then call update on that sObject.
When I ran the update after setting only 3 fields through the .set method, I got a really strange permissions error result from nforce, that I was trying to set fields that I were never updated via set methods. I discovered that if you take the object from getRecord and set even 1 field on the returned sObject for update, you are telling nforce to try and update every field. This is problematic, because by default Salesforce restricts several fields from being updated, even with admin level users. So this update will usually fail.
I cannot determine what a good refactor would be to prevent this. I do believe that maintainers should spell this out in the documentation, by saying next to update record, that if you already have an sObject and just want to update a few fields, it is much better to create a brand new task and set the id.
The text was updated successfully, but these errors were encountered: