0
<apex:page controller="c1" showHeader="false" sidebar="false">
<apex:form>

<apex:pageBlock>
<apex:pageBlockSection title="Login page">
<apex:inputText label="Name" title="Name" value="{!Name}"/>
<apex:inputText label="Ucode" title="Ucode" value="{!Ucode}"/>

</apex:pageBlockSection>
<apex:commandButton value="Dep" action='{!Dep}'/>

</apex:pageBlock>
</apex:form>

</apex:page>

public class c1 {
    public string Name{set;get;}
    public string Ucode{set;get;}
    PageReference P1;

    public PageReference Dep() {
    Employee__c obj;

   obj=[select Emp_Name__c,Ucode__c from Employee__c where Emp_Name__c='Saurabh' AND Ucode__c='MG356'];

    if(obj!=null){
       P1 =new PageReference('www.google.com/');
     }
    else {
       P1 =new PageReference('https://mail.google.com/mail/u/0/#inbox');    
     }
   return P1;
   }
}

Why it is showing this error?

Formula Expression is required on the action attributes

3
  • can anyone tell me pls Jul 7, 2019 at 13:48
  • 1
    This is a community site, and it's a little quiet on Sundays. Please don't use comments and notes in your question to push for fast responses - it won't accomplish anything, and it's often seen as a little rude.
    – David Reed
    Jul 7, 2019 at 13:51
  • In the meantime, you can help yourself get high-quality and swift responses by taking some time to format your code cleanly with readable indentation, and adding relevant tags, like visualforce. Could you make an edit to accomplish those changes?
    – David Reed
    Jul 7, 2019 at 13:54

2 Answers 2

1

The code exactly as posted (with the duplicate markup removed, the custom object query commented out but with the uncommon single quotes left in) compiles and runs fine in a scratch org of mine. If this code is a cut down version, then the problem probably lies in the code you have not included. If this is the exact code, cut and paste it from here into your org.

To echo David Reed's point, the clearer your code and question are, the better the chances of a good answer so ensure e.g. the indenting is good when you post code or page markup.

-1

change this

P1 =new PageReference('www.google.com');

To this

P1 =new PageReference('https://www.google.com');

2
  • Israel, welcome to SFSE. Please take a sec to read How to Answer - could you clarify how exactly this change would impact the error that the poster is seeing?
    – David Reed
    Jul 8, 2019 at 11:30
  • I copied the code from the question and also got the same error. When I made this change the error disappeared. Jul 8, 2019 at 14:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .