Created
December 22, 2011 12:32
-
-
Save palaniraja/1510154 to your computer and use it in GitHub Desktop.
attaching binary data to Salesforce attachment obj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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