function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
hoomelhoomel 

documents and attaching them to email

Hello,

 

I would enable the our users to select any document from a folder an attach it to an email.

I already have the functionality to select existing attachments and to upload a file, but I do not seem to get the correct list of document folders.

 

What I would like to do is:

A drop-down selectList to select the documents' folder.

Then a selectList to show the documents in the selected folder and let the user select the documents he wants to attach to the emailMessage.

 

Currently this is where I am stuck. The list of folders always contains every users' personal folder. I would rather use the same list that is displayed when accessing the Document object.

Is there any way to mimic the behavior of that picklist?

 

Regards,

hoomel

Best Answer chosen by Admin (Salesforce Developers) 
hoomelhoomel

Actually I knew that already, but thanks anyway.

 

My 'problem' solved itself pretty quick.

As administrator, I saw everyone's personal folder and some folders with empty names and only stars as the name.

 

Logging in as a standard user, I realized that these folders are not visible.

So everything is correct there and the selectList works completely fine.

I just had some doubts because of all those unwanted folders showing up.

 

Nevertheless, thanks for the reply!


Regards,

hoomel

All Answers

yashagarwalyashagarwal

You need to query all document folder names and Ids and use that in a VF page select  list .

 

The Apex code for that :

 

        for(Folder fol : [SELECT Id, Name FROM Folder WHERE Type = 'Document'])

 

This will return the ids and names of all the folders in your org , using which you can create a select list and then query the documents for the selected folder based on folder id;

 

// query the documents based on the folder id
        listDocs = [Select Id,name from Document where folderId =:selectedFolder];

 

Hope that helps.

hoomelhoomel

Actually I knew that already, but thanks anyway.

 

My 'problem' solved itself pretty quick.

As administrator, I saw everyone's personal folder and some folders with empty names and only stars as the name.

 

Logging in as a standard user, I realized that these folders are not visible.

So everything is correct there and the selectList works completely fine.

I just had some doubts because of all those unwanted folders showing up.

 

Nevertheless, thanks for the reply!


Regards,

hoomel

This was selected as the best answer
Seema27Seema27

Hi,

 

I want to implement similar functionality as standard send email functionality, in which i want exact replica of Attach file page. I dont have any idea about emails sending and attachments. Can anyone help ?

 

Thanks,

Seema

hoomelhoomel

What exactly do you need help with?

 

I have created a page to mimic the email functionality but without replicating the Attach file page (not possible at all?). Maybe I can help you in some way?

 

Regards,

Marc