You need to sign in to do that
Don't have an account?
[zkSforce] problems with "update" method
Hi, maybe I am using the methods not in the intended way - a very basic example app would be soooo great!!!!
I have a little learning app on a free developper instance of SFDC.
What I achieved:
- I send out a "queryAll" and got reading access to all of the fields in the result (select Id,Name From Opportunity)
What does not work:
- update
What did I do and how does it go wrong:
- I took one of the 31 objects of the query result and put it into a new NSArray
- I sent an "update" with this one element array
- The runtime says
INVALID_TYPE: sObject type '' is not supported. If you are attempting to use a custom object, be sure to append the '__c' after the entity name. Please reference your WSDL or the describe call for the appropriate names.
There's a bug in the reading of id and type from query & retreive calls, I need to publish the new version with that fix. Having said that, its actually bad practice to do query/update with the objects you got from query because you'll be sending back all the fields you queried, rather than just the subset you want to actually change.
As for your compiler warning, NSDictionary is a read-only dictionary, the setters are part of a subclass of NSDictionary called NSMutableDictionary (this is a common pattern in cocoa), you should be changing the feilds on the object via the methods on ZKSObject, not by manipulating the contained fields dictionary.
// setting a fieldValue to nil will automatically put it in the fieldsToNull collection
// setting a fieldValue to non nil will automatically remove it from the fieldsToNull collection
- (void)setFieldValue:(NSObject *)value field:(NSString *)field;
- (void)setFieldDateTimeValue:(NSDate *)value field:(NSString *)field;
- (void)setFieldDateValue:(NSDate *)value field:(NSString *)field;
- (void)setFieldToNull:(NSString *)field;
All Answers
There's a bug in the reading of id and type from query & retreive calls, I need to publish the new version with that fix. Having said that, its actually bad practice to do query/update with the objects you got from query because you'll be sending back all the fields you queried, rather than just the subset you want to actually change.
As for your compiler warning, NSDictionary is a read-only dictionary, the setters are part of a subclass of NSDictionary called NSMutableDictionary (this is a common pattern in cocoa), you should be changing the feilds on the object via the methods on ZKSObject, not by manipulating the contained fields dictionary.
// setting a fieldValue to nil will automatically put it in the fieldsToNull collection
// setting a fieldValue to non nil will automatically remove it from the fieldsToNull collection
- (void)setFieldValue:(NSObject *)value field:(NSString *)field;
- (void)setFieldDateTimeValue:(NSDate *)value field:(NSString *)field;
- (void)setFieldDateValue:(NSDate *)value field:(NSString *)field;
- (void)setFieldToNull:(NSString *)field;
I updated the zksforce page with the fixed version of the library, and an additional sample and links.
Thanks, that very kind.
Great library, great service - sometimes I would feel better, when having paid something for s.o. work!
Cheers
Thomas