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
Edwards71Edwards71 

Notes and attachments in Account object - prevent showing entries made in other objects

Is it possible to surpress the Notes and Attachments in the Account object from picking up all notes made in other objects that relate to that Account? When viewing the account record the notes are obviously all out of context.

 

I'm guessing I need a VF page with an extension to acheive this?

 

Thanks in advance!

Best Answer chosen by Admin (Salesforce Developers) 
sf_believersf_believer

Hi Edward,

 

still banging around on your question....

 

VF  Page:

<apex:page standardcontroller="Account" showheader="false" extensions="AccountNotes" cache="true" >
<apex:form >
<apex:pageBlock title="Notes">
        <apex:pageBlockTable value="{!Notes}" var="item" cellpadding="10" rules="all" styleclass="pageblock" >       
            <apex:column value="{!item.LastModifiedDate}" />
            <apex:column value="{!item.title}" />
            <apex:column value="{!item.body}" />
            <apex:column value="{!item.OwnerId}"/>
        </apex:pageBlockTable>
    </apex:pageBlock>
   
    <apex:pageBlock title="Attachments">
        <apex:pageBlockTable value="{!DocAttachment}" var="item" cellpadding="10" rules="all" styleclass="pageblock" >       
            <apex:column ><apex:commandLink action="/{!item.Id}" target="_blank" value="{!item.Name}" /></apex:column>
            <apex:column value="{!item.LastModifiedDate}" /> 
            <apex:column value="{!item.name}" />
            <apex:column value="{!item.OwnerId}"/>
        </apex:pageBlockTable>
    </apex:pageBlock>
   </apex:form>
   </apex:page>

 

Controller (no change to your code):

public class AccountNotes {
  // Extension controller for Visualforce page
 
    public AccountNotes(ApexPages.StandardController controller) {
    }
   
    Public Note [] getNotes (){
     return [Select Id, IsDeleted, ParentId, Title,IsPrivate, Body, OwnerId, CreatedDate, CreatedById,LastModifiedDate, LastModifiedById, SystemModstamp FROM Note where ParentId= :System.currentPageReference().getParameters().get('id') Order by LastModifiedDate DESC];
       
        }
       
     Public Attachment [] getDocAttachment () {
        return [Select Id, IsDeleted, ParentId, Name, IsPrivate, ContentType, BodyLength, Body, OwnerId, CreatedDate,
        CreatedById, LastModifiedDate, LastModifiedById, SystemModstamp, Description FROM Attachment
        where ParentId= :System.currentPageReference ().getParameters().get('id')
        Order by LastModifiedDate DESC];
       
        }
  }

 

 

 

 

 

 

All Answers

kevindotcarkevindotcar

Hi-

 


Yeah, I think you need a page to do this - like:

<apex:page standardController="Activity" extensions="myActivityControllerExtension">
    <apex:pageBlock title="My filtered tasks">
        <apex:pageBlockTable value="{!account.Id}" var="item">
           <apex:column value="{!item.name}"/>   /*...and all your other stuff */
        </apex:pageBlockTable>
    </apex:pageBlock>
</apex:page>

 ...And the myControllerExtension would return the tasks filtered on your specific criteria.

Put the above page snippet on your account page layout and it should be all OK.... But it definitely is NOT a "clicks only"  solution.

 

 

sambasamba

Yes, you need a VF and add it to Account page layout. I think it wil take about 3 hours.

 

Please send your develope account to my email if you want to let me do it.

 

Thanks,

Samba

Edwards71Edwards71

thanks - I am able to display the Notes and Attachments using an extension easily enough - however the attachment just shows the file name.  What do I need to do to be able to click on the attachment file name to open it up?

 

 

<apex:page standardcontroller="Account" showheader="false" extensions="AccountNotes" cache="true" >

<apex:pageBlock title="Notes">

        <apex:pageBlockTable value="{!Notes}" var="item" cellpadding="10" rules="all" styleclass="pageblock" >

       
            <apex:column value="{!item.LastModifiedDate}" />
        <apex:column value="{!item.title}" />

            <apex:column value="{!item.body}" />
            <apex:column value="{!item.OwnerId}"/>


        </apex:pageBlockTable>


    </apex:pageBlock>
   
    <apex:pageBlock title="Attachments">

        <apex:pageBlockTable value="{!DocAttachment}" var="item" cellpadding="10" rules="all" styleclass="pageblock" >

       
            <apex:column value="{!item.LastModifiedDate}" />
    

            <apex:column value="{!item.name}" />
            <apex:column value="{!item.OwnerId}"/>


        </apex:pageBlockTable>


    </apex:pageBlock>




   </apex:page>

kevindotcarkevindotcar

 

Hi Edward71,That was the

 

...  /*...and all your other stuff */

 

comment I made in the previous ststement.


If you have a controller for your  VF page, post it and we can all take a look at   it.

 

 

 

Edwards71Edwards71

here you go - thanks

 

public class AccountNotes {

  // Extension controller for Visualforce page

 

    public AccountNotes(ApexPages.StandardController controller) {

    }

   

    Public Note [] getNotes (){

     return [Select Id, IsDeleted, ParentId, Title,IsPrivate, Body, OwnerId, CreatedDate, CreatedById,LastModifiedDate, LastModifiedById, SystemModstamp FROM Note where ParentId= :System.currentPageReference().getParameters().get('id') Order by LastModifiedDate DESC];

       

        }

       

     Public Attachment [] getDocAttachment () {

        return [Select Id, IsDeleted, ParentId, Name, IsPrivate, ContentType, BodyLength, Body, OwnerId, CreatedDate,

        CreatedById, LastModifiedDate, LastModifiedById, SystemModstamp, Description FROM Attachment

        where ParentId= :System.currentPageReference ().getParameters().get('id')

        Order by LastModifiedDate DESC];

       

        }

sf_believersf_believer

Hi Edward,

 

still banging around on your question....

 

VF  Page:

<apex:page standardcontroller="Account" showheader="false" extensions="AccountNotes" cache="true" >
<apex:form >
<apex:pageBlock title="Notes">
        <apex:pageBlockTable value="{!Notes}" var="item" cellpadding="10" rules="all" styleclass="pageblock" >       
            <apex:column value="{!item.LastModifiedDate}" />
            <apex:column value="{!item.title}" />
            <apex:column value="{!item.body}" />
            <apex:column value="{!item.OwnerId}"/>
        </apex:pageBlockTable>
    </apex:pageBlock>
   
    <apex:pageBlock title="Attachments">
        <apex:pageBlockTable value="{!DocAttachment}" var="item" cellpadding="10" rules="all" styleclass="pageblock" >       
            <apex:column ><apex:commandLink action="/{!item.Id}" target="_blank" value="{!item.Name}" /></apex:column>
            <apex:column value="{!item.LastModifiedDate}" /> 
            <apex:column value="{!item.name}" />
            <apex:column value="{!item.OwnerId}"/>
        </apex:pageBlockTable>
    </apex:pageBlock>
   </apex:form>
   </apex:page>

 

Controller (no change to your code):

public class AccountNotes {
  // Extension controller for Visualforce page
 
    public AccountNotes(ApexPages.StandardController controller) {
    }
   
    Public Note [] getNotes (){
     return [Select Id, IsDeleted, ParentId, Title,IsPrivate, Body, OwnerId, CreatedDate, CreatedById,LastModifiedDate, LastModifiedById, SystemModstamp FROM Note where ParentId= :System.currentPageReference().getParameters().get('id') Order by LastModifiedDate DESC];
       
        }
       
     Public Attachment [] getDocAttachment () {
        return [Select Id, IsDeleted, ParentId, Name, IsPrivate, ContentType, BodyLength, Body, OwnerId, CreatedDate,
        CreatedById, LastModifiedDate, LastModifiedById, SystemModstamp, Description FROM Attachment
        where ParentId= :System.currentPageReference ().getParameters().get('id')
        Order by LastModifiedDate DESC];
       
        }
  }

 

 

 

 

 

 

This was selected as the best answer
Edwards71Edwards71

Perfect - just what was needed. Thanks very much for your promptness with this one!