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
ahammad skahammad sk 

Create Edit page using Visualforce standard controller...?

Hi,
 
In visualforce edit page "Edit" and "Delete" links are not working.

<apex:page standardController="contact" recordSetVar="contacts">
<apex:pageBlock title="Contacts" mode="Edit">
   <apex:form >
      <apex:pageBlockTable value="{!Contacts}" var="contact" > 
      
      <apex:column >
      <apex:facet name="header">action</apex:facet>
      <apex:commandLink value="Edit" action="{!edit}" />
      </apex:column> 
       
       <apex:column >
       <apex:facet name="header">action</apex:facet>
       <apex:commandLink value="Delete" action="{!delete}" />
       </apex:column> 
     
      <apex:column value="{!contact.Name}"/> 
      <apex:column value="{!contact.MailingCity}"/> 
      <apex:column value="{!contact.Phone}"/>
      </apex:pageBlockTable>
   </apex:form>
</apex:pageBlock>
</apex:page>
Best Answer chosen by ahammad sk
Mudasir WaniMudasir Wani
Dear Ahmad,

For delete operation we need to pass Id 
Code modified 
<apex:column >
                <apex:facet name="header">action</apex:facet>
                <apex:inputHidden value="{!contact.Id}"/>
                <apex:commandLink value="Delete" action="{!delete}" />
 </apex:column>

Please use the below code

<apex:page standardController="contact" recordSetVar="contacts">
    <apex:pageBlock title="Contacts" mode="Edit">
       <apex:form >
          <apex:pageBlockTable value="{!Contacts}" var="contact" > 
          
          <apex:column >
          <apex:facet name="header">action</apex:facet>
          <apex:commandLink value="Edit" action="{!edit}" />
          </apex:column> 
           
           <apex:column >
                <apex:facet name="header">action</apex:facet>
                <apex:inputHidden value="{!contact.Id}"/>
                <apex:commandLink value="Delete" action="{!delete}" />
           </apex:column> 
          <apex:column value="{!contact.Id}"/>
          <apex:column value="{!contact.Name}"/> 
          <apex:column value="{!contact.MailingCity}"/> 
          <apex:column value="{!contact.Phone}"/>
          </apex:pageBlockTable>
       </apex:form>
    </apex:pageBlock>
</apex:page>
 

Please mark this as solution if this solves your problem, So that if anyone has this issue this post can help
 

All Answers

Mudasir WaniMudasir Wani
Dear Ahmad,

For delete operation we need to pass Id 
Code modified 
<apex:column >
                <apex:facet name="header">action</apex:facet>
                <apex:inputHidden value="{!contact.Id}"/>
                <apex:commandLink value="Delete" action="{!delete}" />
 </apex:column>

Please use the below code

<apex:page standardController="contact" recordSetVar="contacts">
    <apex:pageBlock title="Contacts" mode="Edit">
       <apex:form >
          <apex:pageBlockTable value="{!Contacts}" var="contact" > 
          
          <apex:column >
          <apex:facet name="header">action</apex:facet>
          <apex:commandLink value="Edit" action="{!edit}" />
          </apex:column> 
           
           <apex:column >
                <apex:facet name="header">action</apex:facet>
                <apex:inputHidden value="{!contact.Id}"/>
                <apex:commandLink value="Delete" action="{!delete}" />
           </apex:column> 
          <apex:column value="{!contact.Id}"/>
          <apex:column value="{!contact.Name}"/> 
          <apex:column value="{!contact.MailingCity}"/> 
          <apex:column value="{!contact.Phone}"/>
          </apex:pageBlockTable>
       </apex:form>
    </apex:pageBlock>
</apex:page>
 

Please mark this as solution if this solves your problem, So that if anyone has this issue this post can help
 

This was selected as the best answer
ahammad skahammad sk
Hi,

Thanks your reply..

I modified the code with:

<apex:column >
       <apex:facet name="header">action</apex:facet>
       <apex:inputHidden value="{!contact.Id}"/>
       <apex:commandLink value="Delete" action="{!delete}" />
 </apex:column> 
 
But the issue is not able to see "Edit" and "Delete" links in each record of action column.  



 
Mudasir WaniMudasir Wani

I don't feel there should be any issue.
I have tried the code in my Developer org it is showing all links.
try it in your developer org and let me know if same error persists.

Your URL should be 

http://yoursalesforceInstanceaddress/apex/PageName?id=contactId

Please mark this as solution if this solves your problem, So that if anyone has this issue this post can help

ahammad skahammad sk
Hi,

Thanks your reply........

If we pass "contactid" in url then it is showing EDIT and DELETE links.

For display all the conact records we dont need to pass contactid,  But why we are passing "contactid".

Thanks
Mudasir WaniMudasir Wani
To reference a particular records we need to have a unique field to identify it.
In salesforce standard operations we use Id,
If you use a custom delete function then you can have any unique field.

For Example.
Say I need to delete  a record whose unique field name is myEmployeeId
Then you need to pass this id to delete that particular record.

Hope this makes sense.