Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
attaching binary data to Salesforce attachment obj
ZKSObject *attachment = [ZKSObject withType:@"Attachment"];
[attachment setFieldValue:[NSString stringWithFormat:@"Nameofyourattachment%@.png", [NSDate date]] field:@"Name"];
[attachment setFieldValue:@"a07M0000000FV5VIAW" field:@"ParentId"];
NSData *cSign = UIImagePNGRepresentation([UIImage imageNamed:@"signature.png"]);
[attachment setFieldValue:[cSign base64EncodedString] field:@"Body"];
[[FDCServerSwitchboard switchboard] create:[NSArray arrayWithObject:attachment] target:self selector:@selector(saveAttachmentToSFResult:error:context:) context:attachment];
/*Call back from SF when done*/
- (void)saveSignatureToSFResult:(NSArray *)results error:(NSError *)error context:(id)attachment
if (results && !error){
NSString* attachmentId = [[results objectAtIndex:0] id];
NSLog(@"Attachment ObjId: %@ saved to Salesforce", attachmentId);
else if (error){
NSLog(@"Attachment %@", [error description]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment