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
Naveen Kannoju02547126464965992Naveen Kannoju02547126464965992 

note and attachment having edit button i want to take that functionality in vf page

Best Answer chosen by Naveen Kannoju02547126464965992
JeeTJeeT
Replace you code
<apex:column >
          <a href="/{!n.id}/e"> Edit </a>
 </apex:column>
with
<apex:column >
   <a href="/{!attachment.id}/e"> Edit </a> |
   <apex:commandLink value="View" action="{!deleteRecord}">
        <apex:param name="recID" value="{!attachment.id}" assignTo="{!controllerVariable}"/>
   </apex:commandLink> | 
   <a href="/{!attachment.id}/e" target="_blank"> View </a> |
</apex:column>
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

JeeTJeeT
I have written a rough code..
<apex:pageBlockTable value="{!attachmentList}" var="attachment">
	<apex:column>
		<a href="/{!attachment.id}/e"> Edit </a>
	</apex:column>	
	<apex:column value="{!attachment.Name}" />
<apex:pageBlockTable>
Hope above code will help you.
 
Naveen Kannoju02547126464965992Naveen Kannoju02547126464965992
Hi..JEET

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
 
JeeTJeeT
Replace you code
<apex:column >
          <a href="/{!n.id}/e"> Edit </a>
 </apex:column>
with
<apex:column >
   <a href="/{!attachment.id}/e"> Edit </a> |
   <apex:commandLink value="View" action="{!deleteRecord}">
        <apex:param name="recID" value="{!attachment.id}" assignTo="{!controllerVariable}"/>
   </apex:commandLink> | 
   <a href="/{!attachment.id}/e" target="_blank"> View </a> |
</apex:column>
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
}


 
This was selected as the best answer