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

Help on Notes and Attachments Rollup

I want all the Notes and Attachment of Contacts getting rolled up in a different custom Objects (Inline Visualforce Section).


Right now i am able to roll up the Attachments but the challenge is both notes & Attachment getting rolled up(Since we need to query on two different objects and the result is stored in two different list).


So how can i return two different lists to the page block table Section


Below is my tried Code:


VF Page:

<apex:page showHeader="false" standardController="Household_Group__c" extensions="HouseHoldntesattach"  >
            <apex:form id="form" >
                  <apex:pageBlock >
                <apex:pageBlockTable value="{!wrapper }" var="tas" id="filteredtasks"  width="100%" >
                <apex:column >
                    <apex:column >
                    <apex:facet name="header">
                    <apex:outputPanel layout="inline">
                       <apex:outputText value="{!tas.not2.Title }"> </apex:outputText><br/>
                       <apex:outputText value="{!tas.attach2.Name}"> </apex:outputText> 


public class HouseHoldntesattach{

    public List<Note> not1 {get; set;}
    public List<Attachment> attch1 {get; set;}
    public List<MyWrapper> wrapper {get; set;}
    string st;
    public Household_Group__c objhg {get;set;}

    public HouseHoldntesattach(ApexPages.StandardController controller)
    st = controller.getId();
    objhg = (Household_Group__c )controller.getRecord();

     list<attachment> attach = new list<attachment>();
   // list<Note> not= new list<Note>();
         list<Household_Member__c> Childmember = new list<Household_Member__c>();
        Childmember =[select id,Member__c from Household_Member__c where Household_Group__c= :st and Incl_in_Rollup__c = true ];//HH MEMBER ID IS STORED HERE
        list<string> Childmemberids=new list<string>();
        for(Household_Member__c HHacc:Childmember ){
        Childmemberids.add(HHacc.Member__c );
        for(contact con:[select id from contact where AccountId in : Childmemberids]){

 attch1 =[select id,name,LastModifiedDate,CreatedById  from attachment where ParentId in :Childmemberids ];
        not1 =[SELECT Id,LastModifiedDate,Title FROM Note where ParentId in :Childmemberids ];
         wrapper = new List<MyWrapper>() ;
           // wrapper.add(new MyWrapper(not1 , attch1 )) ;
    public class MyWrapper
        public Note not2{get; set;}
        public Attachment attach2{get; set;}
        public MyWrapper(Note not1 , Attachment attch1 )
            not2= not1 ;
            attach2= attch1  ;




Thanks in Advance

Salesforce Hidden FactsSalesforce Hidden Facts
Instead of using page block table .You should iterate list by using repeat
And take page bock section inside your page block ..Take 2 page block
sections one for attachment and other for notes . And inside that use repeat
to iterate your list .

Other thing I noticed is why you are taking wrapper class . I guess without taking
that also you can get your expected result