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
Srini GiridharSrini Giridhar 

Need help in displaying related list on a VF page

I have created a VF page similar to standard Task page. However, I am unable to display attachments section in related list.

here is what I am doing in the apex page.
....
....
</apex:form>
<apex:pageBlock >
                <apex:pageblockSection title="Notes and Attachments" id="tabNoteAtt">
               <apex:relatedList list="Attachments" subject="{!task}"/>
</apex:pageblockSection>
</apex:pageBlock>

</apex:page>


Am I missing something? I appreciate your help.
BalajiRanganathanBalajiRanganathan
Try this
<apex:relatedList subject="{!task}" list="NotesAndAttachments" />
Srini GiridharSrini Giridhar
Hi Balaji,

I tried this and also list="CombinedAttachments" but it doesnt list anything.

Also, I dont even see "Attach File" button I see on the standard task page. 

Thanks,
-Srini
BalajiRanganathanBalajiRanganathan
Ok Use the below and make sure allow activities is checked in the object definition.
<apex:relatedList list="CombinedAttachments" />

you dont need to use subject="{!task}" or you have to use subject="{!task.id}"
BalajiRanganathanBalajiRanganathan
Also make sure that you are passing some taskid in the url. i think it will show empty if there is no id

apex/yourpage?id=a3en00000004Jmt
Srini GiridharSrini Giridhar
Thanks for taking time to help me out Balaji.

I tried both now. still no luck.

Little info that may help. I have added a button called "Custom Task" on account object. on click of this button, my custom VF page for adding new task will open. It is here that I want to display the attachments. just like it would happen in the standard "new task" functionality.

my doubt is, can we have related list in the add record (edit) mode? I understand that a task id is required to get the related list but the task and attachment both would be added on the same screen. In that case the task id would be empty. Isn't it?

-Srini
BalajiRanganathanBalajiRanganathan
you can try the link below. you need to have custom code in your controller extn to achive this

http://www.forcetree.com/2011/02/upload-file-as-attachment-to-record.html