Skip to content

Instantly share code, notes, and snippets.

@palaniraja
Created December 22, 2011 12:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save palaniraja/1510154 to your computer and use it in GitHub Desktop.
Save palaniraja/1510154 to your computer and use it in GitHub Desktop.
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