This is my code

<apex:page sidebar="false" showHeader="false" controller="getmyacceditdel">
 <apex:form >
   <apex:pageBlock >
    <apex:pageBlockTable value="{!myaccount}" var="acc" columnsWidth="90px" >

        <apex:column headerValue="EDIT">
         <apex:outputLink value="{!acc.id}e" id="edit">EDIT</apex:outputLink>

            <apex:column headerValue="DELETE">
             <apex:commandLink action="{!delacc}">Del
              <apex:param name="idtodel" value="{!acc.id}" assignTo="{!recid}"/>

                    <apex:column headerValue="Name">
                     <apex:commandLink value="{!acc.name}" action="{!accountclicked}" reRender="contable">
                      <apex:param name="idtocon" value="{!acc.id}" assignTo="{!recid}"/>

                                          <apex:pageblock >
                                         <apex:pageBlockTable value="{!contactinfo}" var="c" id="contable">
                                        <apex:column value="{!c.firstname}"/>
                                       <apex:column value="{!c.lastname}"/> 


Controller :

public with sharing class getmyacceditdel {

   public list<contact>contactinfo{get;set;}
   public string recid{set;get;}

    public pagereference delacc() {
      Account ac=[select id,name from account where id=:recid];
       delete ac;

       pagereference ref = new pagereference('apex/getmyacceditdel');
       return ref;

    public list<Account> getMyaccount() {
        return[SELECT id,name from Account ORDER BY lastModifiedDate DESC LIMIT:10];

    public void accountclicked() {
    contactinfo =[select id,firstname,lastname from contact where AccountId=:recid];


When am trying to delete the account,the error message displayed is

Formula Expression is required on the action attributes.

Can any one please correct the code.

  • When exactly is the error occuring - on saving the page or on clicking the "Del" link? – Rob Aug 25 '15 at 12:22
  • @Rob hi.... when am clicking the del link then am getting the error. – Sravanthy Aug 25 '15 at 12:32

In your controller, try changing:

pagereference ref = new pagereference('apex/getmyacceditdel');


pagereference ref = new pagereference('/apex/getmyacceditdel');

Note the forward slash / at the start of the PageReference constructor argument.

See the official docs on the PageReference(partialURL) constructor for more details.

  • I had this error few days ago and this should definitely work. – javanoob Aug 25 '15 at 13:16
  • @Rob...hey thank you it worked.....i was able to delete the custom accounts i have created .I think we can edit the standard accounts but we can't delete them...is that right..? – Sravanthy Aug 25 '15 at 13:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.