+ Start a Discussion
Del_SantosDel_Santos 

How to specify the destination folder for files uploaded

Hi,

 

I saw this code online when i am researching but i don't know how can i change the destination folder of my uploaded file. Instead of current users "My Personal Documents" folder, I created a new folder "Online Applications"

 

Could someone help me please. Thanks!

 

 


public PageReference upload() {  
document.AuthorId = UserInfo.getUserId(); 
document.FolderId = UserInfo.getUserId();  <-- i need to change the destination to "Online Applications" folder.

insert mydoc;
        return NULL;
}  

 

Thanks,

Del

 

 

Best Answer chosen by Admin (Salesforce Developers) 
Navatar_DbSupNavatar_DbSup

Hi,

Try the bleow code snippet as reference:

public PageReference upload() { 

document.AuthorId = UserInfo.getUserId();

Folder folderid=select id from folder where name='Online Applications';

document.FolderId = folderid;  <-- i need to change the destination to "Online Applications" folder.

insert mydoc;

        return NULL;

}

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved. 

All Answers

Navatar_DbSupNavatar_DbSup

Hi,

Try the bleow code snippet as reference:

public PageReference upload() { 

document.AuthorId = UserInfo.getUserId();

Folder folderid=select id from folder where name='Online Applications';

document.FolderId = folderid;  <-- i need to change the destination to "Online Applications" folder.

insert mydoc;

        return NULL;

}

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved. 

This was selected as the best answer
Del_SantosDel_Santos

Hi Ankit,

 

Thanks for your usual help.

I have figured it out also, i am missing the single quotes from both sides. I chose to indicate the folder id.

 

sample:

 '022020121Jimh';

 

Thanks Ankit!,

 

Regards,

Del