Use Case
Notes & Attachments section is not customizable of any
object in Salesforce.
Sometimes we need to know when a note or attachment was
added and by whom so that critical business decisions can be taken based on it.
For example,
• If
multiple sales people are working on a deal, adding notes and attachment.
• If
there are several attachments that look similar, it is important to know which
one is the latest attachment.
• If
users are extensively using notes to communicate the progress on a deal, it can
help perform analysis based on number of notes/attachments created by different
team members and how the deal was won/lost.
Solution
We should create a visual force page and apex class for a
particular Object on which we want to show created date. After creating this
page use this page as an inline visual force page from page layout.
Here is the
Example for Account Object, you can change Object and fields as per business requirement
or project need.
Reusable Code
Apex class
private List<attachment> attz;
private Account accnt;
public AccountNotes(ApexPages.StandardController controller) {
this.accnt= (Account)controller.getRecord();
}
public List<attachment> getAttz()
{
if (accnt == null)
return null;
attz = [Select id, Name, CreatedById,LastModifiedById,LastModifiedDate, CreatedDate from Attachment where ParentID = :accnt.id];
return attz;
}
}
|
Visualforce Page
<apex:page standardController="Account"
extensions="AccountNotes">
<apex:form >
<apex:pageblock id="CustomList" title="Notes
& Attatchment" >
<apex:pageBlockTable value="{!attz}"
var="o" rendered="{!NOT(ISNULL(attz))}">
<apex:column
value="{!o.Name}"/>
<apex:column
value="{!o.CreatedById}"/>
<apex:column
value="{!o.LastModifiedById}"/>
<apex:column
value="{!o.LastModifiedDate}"></apex:column>
<apex:column value="{!o.CreatedDate
}"/>
</apex:pageBlockTable>
<apex:outputLabel value="No records to
display" rendered="{!(ISNULL(attz))}"
styleClass="noRowsHeader"></apex:outputLabel>
</apex:pageblock>
</apex:form>
</apex:page>
|
To display this related list we need to make section in
page layout and use like an inline visulforce page
No comments:
Post a Comment