+ Start a Discussion
chandraYeruvaRechandraYeruvaRe 

how to upload a file in salesforce.com

Hi ,

 

I have developed a web service using apex code and succesful to invoke it using soap Client.

Now I have one new requirement to upload a file to the custom object. how do I upload a pdf/text file to the custom object from my local file system.Is there any way to do this ? Help Appreciated.

 

Thanks

Chandra.

chandraYeruvaRechandraYeruvaRe

Hi All,

 

I went through the link(http://community.salesforce.com/sforce/board/message?board.id=JAVA_development&thread.id=5574) to create a documnet.Now I got the problem in creating the Folder.

 

In this section Simon told like this "either query for a folderId from the Folder object, or use the UsersId, to create a document in the users private documents folder".I queried the Folders object It was returning me 0 folders.

 

Now my question is I can not create a folder as like this

 

Folder folder = new Folder();

folder.id='MyUserName';(the username which i used to login)

 

Document doc = new Document();Blob blobObj = Blob.valueOf('This is a test String for Blob');

doc.Body=blobObj;

doc.DeveloperName ='NewAuthor';doc.ContentType=

'text/html';

doc.Description=eventDesc;

doc.Name =eventName;

doc.FolderId=folder.Id;

 

Which is giving me an Exception "System.StringException: Invalid id: 'MyUserName'.

 

Can any one please tell how to create the folder in Apex code.with the user specified name.

 

Or is it something like we need to create folders in some other palce ?

 

Thanks

Chandra.

 

iceberg4uiceberg4u

Do you really need a web service to do this?

Can't you use the <apex:inputFile> tag present in Visual Force?

 

 

prageethprageeth
You can't assign an Id for the folder. Id is unique and it is automatically created by Salesforce.