You need to sign in to do that
Don't have an account?
songlan
Load Blob data with Test.loadData
Hello,
I'd like to use Test.loadData to create some attachments with createddate in the past for test purpose. What should I put for the Body field (base64) in the csv file?
Thanks in advance.
HI..
You can use this code to cover blob value in test case
Attachment at= new Attachment();
at.body=blob.valueof('this is test attachment');
In CSV file
use the local address path of the uploading file like
finally your csv file look like this
Hi,
Thanks for your quick response.
I tried with the local path in the csv file, and I got System.StringException: CSV Parse error: Body: value not of required type
You need to enable the bulk API with enable to upload binary attachments in dataloader settings.
Goto dataloader ---settings in that select "Use bulk API" below there is another option called "upload bulk API Batch as Zip file (Enable to upload binary attachments) " select this and save ,
Then you can perform your operation on attachments
ah sorry I'm not using dataloader. I talked about using the method Test.loadData() in unit test.
I can insert attachments with apex code, but this way the created date will be the date of today and it can not be modified, so I tried to use Test.loadData(name of a file) with which I can insert attachments with a specified created date, but I don't know what to put in the Body field.
Follow the instructions in below link ..
http://www.salesforce.com/us/developer/docs/api_asynch/api_bulk.pdf
in that pdf goto the topic "Load Binary attachment."
I hope you can get rid of this ploblem.