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
developerTeamdeveloperTeam 

Visualforce Error: common.formula.FormulaParseException: Syntax error. Found 'if'

Hi,

 

Am facing This Viusalforce Error "common.formula.FormulaParseException: Syntax error. Found 'if'

When I click the "New PortofOrigin" Button of my VF page , Instead of New Record page Am facing an Visualforce Error.......... The code is Below

I have Used an If condition in Value attribute of my TabPanel , I thought this was the reason for Error ...So, resolve this issue and suggest me the way to call an New Record using Formula.

 

<apex:form id="form">
<apex:actionFunction name="setTab" onComplete="return false;" rerender="tabpanel">
<apex:param name="activeTab" assignTo="{!ActiveTab}" value="" />
</apex:actionFunction>

<apex:tabPanel switchType="client" id="tabpanel" value="{!if(ActiveTab != null, ActiveTab, 'tab1')}" tabClass="activeTab" inactiveTabClass="inactiveTab" >
<!-- TAB ONE STARTS -->
<apex:tab title="PortofOrigin" label="PortofOrigin" id="object1" name="tab1" ontabenter="setCookie('apex__counter','tab1');" switchType="client">
<apex:message title="Error"/>

<apex:pageBlock title="PortofOrigin" mode="edit" tabStyle="Sourcing__tab">
  <!-- NEW BUTTON WHICH WHEN CLIKCED FOR -->

        <apex:pageBlockButtons location="top" style="padding-left:70px;">
         <apex:commandButton value="New PortofOrigin" action="{!URLFOR($Action.Port_of_Origin__c.New)}" style="font-size:12px;font-weight:bold;width:120px;"/>
        </apex:pageBlockButtons> 
       
        <apex:pageBlockTable value="{!PortofOriginresults}" var="PortofOrigin" id="PortofOrigintblResults">
           <apex:column > 
           <apex:facet name="header">
            <apex:outputPanel style="font-size:13px;">PortofOrigin Name</apex:outputPanel>
           </apex:facet>
           <apex:outputLink value="/{!PortofOrigin.id}" id="eventlink" >{!PortofOrigin.Name} </apex:outputLink>  
          </apex:column>
        </apex:pageBlockTable>
      </apex:pageBlock>

 -Thank you.

 

kiranmutturukiranmutturu
i hope error is coming because of

{!if(ActiveTab != null, ActiveTab, 'tab1')}
change the above like
{!if(ActiveTab <> null, 'ActiveTab', 'tab1')}
developerTeamdeveloperTeam
yeah. the Error is because of that If Condition .
It is not working with <> , the code you gave........n same Error comes again.....
kiranmutturukiranmutturu
can i have the complete page and class code?
developerTeamdeveloperTeam

I guess it was the formula i had used in the pageblockbutton 


<apex:commandButton action="{!URLFOR($Action.RFQ__c.New)}" value="New RFQ" id="blockUI" />  

// something more to be added or may formula couldn't here

 

the Controller I had used is

public with sharing class extensionController {

    public extensionController()
    {
        Cookie counter = ApexPages.currentPage().getCookies().get('counter');

        // If this is the first time the user is accessing the page,   
        // create a new cookie with name 'counter', an initial value of '1',   
        // path 'null', maxAge '-1', and isSecure 'false'.   
            if (counter ==null) {
                counter = new Cookie('counter','tab1',null,999,false);
                // Set the new cookie for the page  
                ApexPages.currentPage().setCookies(new Cookie[]{counter});
            } else {
        // If this isn't the first time the user is accessing the page  
        // create a new cookie, incrementing the value of the original count by 1  
            
                ActiveTab = String.valueOf(counter.getValue());
            }
            system.debug('@@ActiveTab: ' + ActiveTab);
    }
    
    public string ActiveTab  { get; set; }
    

}

 this was for the value attribute of tabPanel.......  

developerTeamdeveloperTeam

Dear Kiran,

 

Here is my Entire Page and Controller 

<apex:page showHeader="false" id="thePage" controller="extensionController1">
    <script>
        function setCookie(c_name,value)
        {
            var exdate=new Date();
            exdate.setDate(exdate.getDate() + 99);
            var c_value=(escape(value) + : "; expires="+exdate.toUTCString());
            document.cookie=c_name + "=" + c_value;
        }
    </script>
<apex:form id="form">
<apex:actionFunction name="setTab" onComplete="return false;" rerender="tabpanel">
<apex:param name="activeTab" assignTo="{!ActiveTab}" value="" />
</apex:actionFunction>

<apex:tabPanel switchType="client" id="tabpanel" value="{!if(ActiveTab != null, ActiveTab, 'tab1')}" tabClass="activeTab" inactiveTabClass="inactiveTab" >
<!-- TAB ONE STARTS -->
<apex:tab title="tab1" label="tab1" id="object1" name="tab1" ontabenter="setCookie('apex__counter','tab1');" switchType="client">
<apex:message title="Error"/>

<apex:pageBlock title="tab1" mode="edit" tabStyle="Sourcing__tab">
  <!-- NEW BUTTON WHICH WHEN CLIKCED FOR -->

        <apex:pageBlockButtons location="top" style="padding-left:70px;">
         <apex:commandButton value="New PortofOrigin" action="{!URLFOR($Action.Port_of_Origin__c.New)}" style="font-size:12px;font-weight:bold;width:120px;"/>
        </apex:pageBlockButtons> 
       
</apex:pageblock>
</apex:tab>
<!-- TAB TWO STARTS -->

<apex:tab title="tab2" label="tab2" id="object2" name="tab2" ontabenter="setCookie('apex__counter','tab2');" switchType="client">
<apex:message title="Error"/>

<apex:pageBlock title="tab1" mode="edit" tabStyle="Sourcing__tab">
  <!-- NEW BUTTON WHICH WHEN CLIKCED FOR -->

        <apex:pageBlockButtons location="top" style="padding-left:70px;">
         <apex:commandButton value="New PortofOrigin" action="{!URLFOR($Action.Port_of_Origin__c.New)}" style="font-size:12px;font-weight:bold;width:120px;"/>
        </apex:pageBlockButtons> 
       
</apex:pageblock>
</apex:tab>
</apex:tabpanel>
</apex:form>
</apex:page>

 and Controller is: 

public with sharing class extensionController1 {
    
    public string ActiveTab  { get; set; }

    public extensionController1()
    {
        Cookie counter = ApexPages.currentPage().getCookies().get('counter');

        // If this is the first time the user is accessing the page,   
        // create a new cookie with name 'counter', an initial value of '1',   
        // path 'null', maxAge '-1', and isSecure 'false'.   
            if (counter ==null) {
                counter = new Cookie('counter','tab1',null,999,false);
                // Set the new cookie for the page  
                ApexPages.currentPage().setCookies(new Cookie[]{counter});
            } else {
        // If this isn't the first time the user is accessing the page  
        // create a new cookie, incrementing the value of the original count by 1  
            
                ActiveTab = String.valueOf(counter.getValue());
            }
            system.debug('@@ActiveTab: ' + ActiveTab);
    }
}

 The MAIN issue here is with the Value attribute .......... I gues we can rectifiy this issue by placing the value to value={!ifMethod}  and in Controller 

public string getifMethod()

{

if(ActiveTab != null, ActiveTab, 'tab1') // this should be converted I guess to good method
}

Nirmal ChristopherNirmal Christopher
https://developer.salesforce.com/forums/ForumsMain?id=906F000000097IGIAY


check the controller and name attributes once again. i ahd the same issue i followed the above link very carefully i missed the else statement in the controller.