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
Sachin10Sachin10 

ERROR: Formula Expression is required on the action attributes.

Hi,

I'm facing a weird error "Formula Expression is required on the action attributes".

 

My VF Page:

<apex:commandButton value="Log-in"  action="{!loginTest}"/>

 

My Class:

public pagereference loginTest(){
pagereference redirect = new PageReference('apex/newPage');
redirect.setRedirect(true);
system.debug('Hello@@'+redirect);
return redirect;
}

 

But when I click on login button i'm facing a weird error 'Formula Expression is required on the action attributes'.

 

Syntax looks fine,but some how it is not working.

Any help is much appreciated :)

 

Best Answer chosen by Admin (Salesforce Developers) 
Puja_mfsiPuja_mfsi

Hi Sachin,

Yo need to do a minor change in your "loginTest" method in the below line:

 

pagereference redirect = new PageReference('apex/newPage');

 

to  pagereference redirect = new PageReference('/apex/newPage');

 

You need to put the forward slash in front of apex.

 

Please let me know if u have any problem on same and if this post helps you please throw KUDOS by click on star at left.

All Answers

Puja_mfsiPuja_mfsi

Hi Sachin,

Yo need to do a minor change in your "loginTest" method in the below line:

 

pagereference redirect = new PageReference('apex/newPage');

 

to  pagereference redirect = new PageReference('/apex/newPage');

 

You need to put the forward slash in front of apex.

 

Please let me know if u have any problem on same and if this post helps you please throw KUDOS by click on star at left.

This was selected as the best answer
Sachin10Sachin10

Thanks..

somehow missed it..silly me :)

Rich PRich P
For those who find this page searching "Formula Expression is required on the action attributes" and the above answer does not resolve their problem. I received this error when I was developing a data factory class and incorrectly tried to return a string from the action call of an apex:commandButton. For instance, this is incorrect:


in page:

<apex:commandButton action="{!getData}" value="Create Sandbox Data"/>


in controller:

public String getData() {
  String result;
  Boolean success = true;

  // create some data, set success flag accordingly

  return result = success ? 'Data created with success.' : 'Problems were encountered creating sandbox data. Refer to logs for details.';
}


This works and provides feedback:

in page:

<apex:commandButton action="{!getData}" value="Create Sandbox Data"/>
<p />
<apex:repeat value="{!insertResults}" var="insertResult" id="results">
<apex:outputText value="{!insertResult}" /><br />
</apex:repeat>


in controller:

private void setInsertResults(String newString) {
  insertResults.add(newString);
}

public List<String> getInsertResults() {
  return insertResults;
}

public void getData() {
  String result;
  Boolean success = true;

  // create some data, set success flag accordingly

  result = success ? 'Data created with success.' : 'Problems were encountered creating sandbox data. Refer to logs for details.';
  this.setInsertResults(result);
}
NewportNewport
Thanks so much Rich P for bothering to post that.

That solved my problem!
Ashok ChaudharyAshok Chaudhary
click on this link.

http://sales-fundamentals.blogspot.in/2014/09/how-to-navigate-to-another-page-visual.html
Ashok ChaudharyAshok Chaudhary
@Puja_mfsi.
Hi pooja, i m trying to open a new page when click on button using commandLink.
its not working.
my email nareshsaini000111@gmail.com
Anirban RoyAnirban Roy
Dear Friends,

I am trying to open a new thread but somehow it will not allow me to, dont know why !, newbie jerks prolly :(
But I am facing a similar error as above.

My VF Page:

<apex:page controller="BankDetailsController">
     <apex:form >
   <apex:pageBlock >
      <apex:commandButton value="BANK" action="{!getbankDet}"/>
         <apex:pageBlockSection>
             Following are the Bank Details
                   {!Response}    
       </apex:pageBlockSection>
  </apex:pageBlock>
  </apex:form>
</apex:page>

My Controller: calls a web service which I imported as a Apex class in my org <basically its a web service written in another salesforce org of mine>

public class BankDetailsController {
    
    //public string bank { get { return getbankDet(); } }
    public String Response {get; set;}
    public string getbankDet() 
    {

        string accname = 'GoGlobalStrategies';
        partnerSoapSforceCom.Soap myPartnerSoap = new partnerSoapSforceCom.Soap(); 
        partnerSoapSforceCom.LoginResult partnerLoginResult = myPartnerSoap.login('somnath.paul4@cognizant.com', 'MyPasswordgPeEzXp6zqiICng3M8wKQtqd');
        soapSforceComSchemasClassGetbankdet.SessionHeader_element webserviceSessionHeader=new soapSforceComSchemasClassGetbankdet.SessionHeader_element();
        webserviceSessionHeader.sessionId = partnerLoginResult.sessionId;
        soapSforceComSchemasClassGetbankdet.GetBankDetailsofAccount getBankdet=new soapSforceComSchemasClassGetbankdet.GetBankDetailsofAccount();
        getBankdet.SessionHeader=webserviceSessionHeader;
        Response = getBankdet.getBankDetails(accname);
        return Response;
 }
}

When I click on the BANK button in my VF Page, the response should flow in, but actually the error flows out :(

Can anyone tell me where am I going wrong here?
Srisha PyatiSrisha Pyati
<apex:page standardController="Case" >
    <apex:pageBlock >
    <apex:form >
        
        <apex:commandButton action="window.close()" value="Close" onclick="window.close()"/>
        
    </apex:form>
    
   </apex:pageBlock>
    
    
    
</apex:page>


same error ....please need help with this