Define a method for deleting the record in controller
public String controllerVariable {get;set;} // will store from commandLink param deleting record ID
public void deleteRecord(){
// SOQL: Query deleting record details [SELECT is,name.... FROM XXX WHERE id=:controllerVariable]
// DML: delete the queried record
}
public class NotesAndAttachmentEx { public Account acc {get; set;}
public List<Note> notelist{set;get;} public List<Note> noteResList{set;get;} public List<attachment> attachmentslist{set;get;} public NotesAndAttachmentEx(ApexPages.StandardController controller) { acc = (Account) controller.getRecord(); string accid = Apexpages.currentpage().getparameters().get('id'); notelist = [SELECT Id,ParentId,Title,LastModifiedDate,Body,CreatedById FROM Note WHERE ParentId =: accid ]; noteResList=[SELECT Body,LastModifiedById,LastModifiedDate,CreatedDate , CreatedById,Title FROM Note WHERE CreatedDate = Today ORDER BY CreatedDate DESC NULLS FIRST limit 1]; attachmentslist = [SELECT Id,Name,ParentId,LastModifiedDate,Body,ContentType ,CreatedById FROM Attachment WHERE ParentId =: accid ]; }
here i need to put Edit ,Del,View,Action buttons Please help me now as much as possible , here Edit button will work fine but remaining buttons will not work .
Define a method for deleting the record in controller
public String controllerVariable {get;set;} // will store from commandLink param deleting record ID
public void deleteRecord(){
// SOQL: Query deleting record details [SELECT is,name.... FROM XXX WHERE id=:controllerVariable]
// DML: delete the queried record
}
All Answers
please help me again .
<apex:page standardController="Account" extensions="NotesAndAttachmentEx">
<apex:form >
<apex:pageBlock title="Note">
<apex:pageblockButtons location="top">
<apex:commandButton value="Note" action="{!newNote}"/>
</apex:pageblockButtons>
<apex:pageBlockTable value="{!notelist1}" var="n" >
<apex:column >
<a href="/{!n.id}/e"> Edit </a>
</apex:column>
<apex:column >
<a href="/{!n.id}/"> Del </a>
</apex:column>
<apex:column value="{!n.Title}"/>
<apex:column value="{!n.LastModifiedDate }"/>
<apex:column value="{!n.Body}"/>
<apex:column value="{!n.CreatedById }"/>
</apex:pageBlockTable>
</apex:pageBlock>
<apex:pageBlock title="Attachment">
<apex:pageblockButtons location="top">
<apex:commandButton value="Attachment" action="{!newAttachment}"/>
</apex:pageblockButtons>
<apex:pageBlockTable value="{!attachmentslist1}" var="a" >
<apex:column >
<a href="/{!a.id}/e"> Edit </a>
</apex:column>
<apex:column value="{!a.ContentType }"/>
<apex:column value="{!a.LastModifiedDate }"/>
<apex:column value="{!a.CreatedById }"/>
<apex:commandLink / >
</apex:pageBlockTable>
</apex:pageBlock>
<Apex:pageblock title="Recent Items">
<apex:pageBlockTable value="{!noteResList1}" var="r" >
<apex:column value="{!r.Title}"/>
<apex:column value="{!r.CreatedDate }"/>
<apex:column value="{!r.CreatedById }"/>
</apex:pageBlockTable>
</Apex:pageblock>
</apex:form>
</apex:page>
Controller is:
public class NotesAndAttachmentEx
{
public Account acc {get; set;}
public List<Note> notelist{set;get;}
public List<Note> noteResList{set;get;}
public List<attachment> attachmentslist{set;get;}
public NotesAndAttachmentEx(ApexPages.StandardController controller)
{
acc = (Account) controller.getRecord();
string accid = Apexpages.currentpage().getparameters().get('id');
notelist = [SELECT Id,ParentId,Title,LastModifiedDate,Body,CreatedById FROM Note WHERE ParentId =: accid ];
noteResList=[SELECT Body,LastModifiedById,LastModifiedDate,CreatedDate , CreatedById,Title FROM Note WHERE CreatedDate = Today ORDER BY CreatedDate DESC NULLS FIRST limit 1];
attachmentslist = [SELECT Id,Name,ParentId,LastModifiedDate,Body,ContentType ,CreatedById FROM Attachment WHERE ParentId =: accid ];
}
public List<note> getnotelist1(){
return notelist;
}
public List<note> getnoteResList1(){
return noteResList;
}
public List<attachment> getattachmentslist1(){
return attachmentslist ;
}
public PageREference newNote()
{
String accid = acc.id;
accid = accid.substring(0, 15);
PageReference pref;
pref = new PageReference('/002/e?parent_id='+accid+'&retURL='+accid);
return pref;
}
public PageReference newAttachment()
{
PageReference pref;
String accid = acc.id;
accid = accid.substring(0, 15);
pref = new PageReference('/p/attach/NoteAttach?pid='+accid+ '&retURL='+accid);
return pref;
}
}
here i need to put Edit ,Del,View,Action buttons
Please help me now as much as possible ,
here Edit button will work fine but remaining buttons will not work .
Please help me.
Thanks
Naveen