You need to sign in to do that
Don't have an account?

Custom CSV upload using apex on button click
Hello All
I have a requirement of taking a csv and uploading records into a object, no validations required. Just parsing the csv and inserting records.
Could anyone point me to any blog/website where I can find this stuff. Any help is appreciated.
I have a requirement of taking a csv and uploading records into a object, no validations required. Just parsing the csv and inserting records.
Could anyone point me to any blog/website where I can find this stuff. Any help is appreciated.
to insert a record in attachment via apex just create a instance of the attachment object and do a DML inser. Something like this
Attachment appAttach = new attachment();
attachment.OwnerId = UserInfo.getUserId();
attachment.ParentId = c.id ;// the record the file is attached to
try {
insert attachment;
appAttach.body = attachment.Body;
appAttach.name = attachment.name;
} catch (DMLException e) {
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Error uploading attachment'));
return null;
} finally {
attachment = new Attachment();
}
appAttach.OwnerId = UserInfo.getUserId();
appAttach.ParentId = appAttachID ;// the record the file is attached to
try {
insert appAttach ;
}............................
If you are getting the attachmet from a REST api or if u wanna send the attachment via email. Parsethe attachment body to a Blob data type (If required)
Please try below link..
http://www.ericsantiago.com/eric_santiago/2011/03/upload-and-parse-csv-via-visualforce.html
Thanks..