Posts

Showing posts from November, 2017

Uploading multiple files as attachments using chaining of actionfunction in single click.

Image
File operations in salesforce are not easy compared to other technologies because of it's governance limits like maximum heap size, maximum string length etc.This post will be explaining how to upload multiple files with single browse by chaining of actionfunction using JavaScript. Limitations of apex : i nputF i le:  1) apex:inputFile cannot be used in conjunction with an action component, apex:commandButton or apex:commandLink that specifies a rerender or oncomplete attribute. So this tag is not useful on complex vf page. 2)This tag can upload only one file at a time. Implementation: In JavaScript function uploadFiles converts attachments body in base-64 encoded string and calls actionFunction saveFileAF(Base64 Encoded attachment body, File Name). In Apex decode base64 string and create attachment. On complete this  again call uploadFiles function in JS for next file. Repeat the same operation for each file. Code: