0

I have a record type for opportunity to which i need to assign this VF page. I am getting an error :

Element type "apex:pageBlock" must be followed by either attribute specifications, ">" or "/>".

VF page

    <apex:page standardController="Opportunity" extensions="CreateOppExtension"  >
      <apex:form >
          <apex:pageBlock title="Opportunity Edit" mode="save" rendered="{if(opportunity.RecordTypeid =="012b0000000M8s5"),true,false}">
          <apex:pageBlockButtons >
            <apex:commandButton action="{!save}" value="Save" />
            <apex:commandButton action="{!cancel}" value="Cancel"/>
          </apex:pageBlockButtons>
    </apex:pageBlock>     
      </apex:form>
    </apex:page> 

Controller:

public class CreateOppExtension {

Opportunity opp {get;set;} 

String Owner {get;set;}

  ApexPages.StandardController GstdController;


 public PageReference save(){
    insert opp;            


    return new PageReference('/'+opp.Id);

}
2
  • By the way, "==" returns a Boolean already. You don't need the if statement. rendered="{!opportunity.RecordTypeid =='012b0000000M8s5'}" – sfdcfox Jun 29 '17 at 12:39
  • Also never hardcode a recordtypeid, it will stop working when you move it to higher sandboxes as the id will change – RedDevil Jun 29 '17 at 13:06
0

Can you try using the code as below:

<apex:pageBlock title="Opportunity Edit" mode="save" rendered="{!if(opportunity.RecordTypeid =='012b0000000M8s5',true,false)}">

2

Replace:

<apex:pageBlock title="Opportunity Edit" mode="save" 
    rendered="{if(opportunity.RecordTypeid =="012b0000000M8s5"),true,false}">

With:

<apex:pageBlock title="Opportunity Edit" mode="save" 
    rendered="{!IF(opportunity.RecordTypeid =='012b0000000M8s5', true, false)}">

Details:

There were following issues for which compiler complains about:

  1. You missed an exclamation sign which is required for merge field.
  2. Use single quotes for wrapping the recordtypes in condition.
  3. true/false statement should be inside the parenthesis of an IF conditon.

    • Better would be get rid of IF condition, the comparison itself returns a Boolean.

      rendered="{!opportunity.RecordTypeid =='012b0000000M8s5'}"
      
0

you need to bind the renderd attribute as your attribute is not bind like this :-

<apex:pageBlock title="Opportunity Edit" mode="save" rendered="{!if(opportunity.RecordTypeid =="012b0000000M8s5"),true,false}">
2
  • @Reshma..I am getting same error – User 7864 Jun 29 '17 at 11:28
  • @DiljaanShaik did you try my method? – sonam mittal Jun 29 '17 at 12:19

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.