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
Edwin HerreraEdwin Herrera 

If Else Conditional Statement

I have to input text area fields. I want to display one of these fields based on the value of the third field. The following is the code I have tried to give the result I want. This code is giving me the follwing error (missing '='). I would like any help I can get. thank you.

{!if ([Work_Item__c.Percent_Complete__c==100]){
    <apex:inputTextarea richText="true" cols="100" rows="15" value="{!Work_Item__c.Final_Status_Summary__c}"/>
}else {
    <apex:inputTextarea richText="true" cols="100" rows="15" value="{!Work_Item__c.Status_Summary__c}"/>   }}
Best Answer chosen by Edwin Herrera
VineetKumarVineetKumar
Closing quote missing for value. Check the below one
<apex:inputTextarea richText="true" cols="100" rows="15" value="{!Work_Item__c.Final_Status_Summary__c}"
rendered="{!IF(Work_Item__c.Percent_Complete__c==100, true, false)}"/>
<apex:inputTextarea richText="true" cols="100" rows="15" value="{!Work_Item__c.Status_Summary__c}"
rendered="{!IF(Work_Item__c.Percent_Complete__c==100, false, true)}"/>

All Answers

Edwin HerreraEdwin Herrera
I used the code you provided and I reviewed it as well. Looks fine to me but I am getting the following error.
Error: Syntax error. Missing ')'

I this does not work, would you have an idea of how else I could get the result I want?
VineetKumarVineetKumar
Can you paste your part of the code?
Edwin HerreraEdwin Herrera
My code is working just fine until I input the line of code you provided. It is so weird that it says a close parentheses is missing. My VF page has a long code so I am providing the code for just that div.

<div id="status">
<div id="sh"><p id="sht">Status Summary</p></div>
<div id="health">
<p id="h3t">Scope/Quality Health<apex:inputField style="margin-bottom:1em" value="{!Work_Item__c.Quality_Scope_Health__c}"/>&emsp;
Schedule Health<apex:inputField style="margin-bottom:1em" value="{!Work_Item__c.Schedule_Health__c}"/>&emsp;
Risk Health<apex:inputField style="margin-bottom:1em" value="{!Work_Item__c.Risk_Health__c}"/></p>
</div>
<div id="srich">
<apex:inputTextarea richText="true" cols="100" rows="15" value="{!IF(Work_Item__c.Percent_Complete__c==100, Work_Item__c.Final_Status_Summary__c, Work_Item__c.Status_Summary__c)}"/>
</div>
</div>
 
VineetKumarVineetKumar
Sorry my bad, input tags don't support the conditional IF, replace the whole 
<apex:inputTextarea richText="true" cols="100" rows="15" value="{!IF(Work_Item__c.Percent_Complete__c==100, Work_Item__c.Final_Status_Summary__c, Work_Item__c.Status_Summary__c)}"/>
by :
<apex:inputTextarea richText="true" cols="100" rows="15" value="{!Work_Item__c.Final_Status_Summary__c} rendered="{!IF(Work_Item__c.Percent_Complete__c==100, true, false)}"/>
    <apex:inputTextarea richText="true" cols="100" rows="15" value="{!Work_Item__c.Status_Summary__c}" rendered="{!IF(Work_Item__c.Percent_Complete__c==100, false, true)}"/>

Do mark my answer as best answer if it helped solve your problem
Edwin HerreraEdwin Herrera
I really thought it was going to resolve my issue. I put in exactly what you showed me but i got the following error.
Error: WIP_STaRT line 86, column 115: Element type "apex:inputTextarea" must be followed by either attribute specifications, ">" or "/>"
Error: Element type "apex:inputTextarea" must be followed by either attribute specifications, ">" or "/>".
VineetKumarVineetKumar
I would again ask you to put your page snippet here.. :)
Edwin HerreraEdwin Herrera
I copied the entire code. I hope this is able to help. The code you provided is bold and italic near the end.


<apex:page standardController="Work_Item__c"  showHeader="false" standardStylesheets="false" applyBodyTag="false" applyHtmlTag="false" docType="html-5.0">
<html>
<style type="text/css">
* { font-family:"Times New Roman", Times, serif; margin:0;  }
div{margin:0;padding:0;margin:auto;}
#container{height:55.2em;width:101em;border:1px solid black;position:relative;}
#Header{height:6em;width:100.7em;border:2px solid black;}
#header1{height:6em;width:25em;float:left;border-top:1px solid black;border-left:1px solid black;border-bottom:1px solid black;text-align:center;}
#header2{height:6em;width:40em;float:right;margin-auto;border:1px solid black;text-align:center;}
#header3{height:6em;width:35em;float:right;border-top:1px solid black;border-right:1px solid black;border-bottom:1px solid black;text-align:center;}
#h1t{margin-top:.1em;font-size:1.25em;}
#h2t{font-size: 3em;margin-top:1em;}
#h3t{margin-top:1em;font-size:1.15em;}
#pc{height:3em;width:13.2em;position:absolute;top:14.5em;left:0;;font-size:1.5em;}
#executive{height:21em;width:50.4em;border:1px solid black;position:absolute;top:6.2em;left:0;}
#status{height:22em;width:50.4em;border:1px solid black;position:absolute;top:9.2em;right:0;}
#health{height:3em;width:50.4em;border-bottom:1px solid black;position:absolute;top:6.2em;right:0;text-align:center;}
#value{height:21em;width:50.4em;border:1px solid black;position:absolute;top:27.2em;left:0;}
#risks{height:21em;width:50.4em;border:1px solid black;position:absolute;top:31.2em;right:0;}
#costs{height:7em;width:50.4em;border:1px solid black;position:absolute;top:48.2em;left:0;}
#sh{height:2em;width:20em;border:1px solid black;position:absolute;top:0;left:0;}
#sht{font-size:1.6em;margin-top:0.2em;}
#business{height:5em;width:50.4em;position:absolute;top:1em;text-align:center;margin-top:1em;border-top:1px solid black;}
#rich{height:18.6em;width:50.2em;position:absolute;top:2.1em;border:1px solid black;}
#srich{height:19.6em;width:50.2em;position:absolute;top:2.1em;border:1px solid black;}
#buttons{height:3em;width:12em;position:absolute;top:14.5em;right:0;;font-size:1.5em;text-align:center;}
</style>

<apex:form >
<div id="container">
<div id="Header">
<div id="header1">
<apex:pageBlock >
<p id="h1t">Work Item ID &emsp;: <apex:outputField value="{!Work_Item__c.Work_Item_ID__c}"/><br/>
Work Item Name: <br/><apex:outputField label="Work Item Name" value="{!Work_Item__c.Name}"/></p>
</apex:pageBlock>
</div>
<div id="header3">
<p id="h3t">Forcasted Finish<apex:inputField value="{!Work_Item__c.Forecasted_Finish__c}"/>&emsp;
Overall Health<apex:inputField value="{!Work_Item__c.Overall_Health__c}"/> <br/> </p>
<p id="h3t">Status as of<apex:inputField value="{!Work_Item__c.Status_as_of__c}"/>&emsp;
LSEF Stage<apex:inputField value="{!Work_Item__c.LSEF_Stage_del__c}"/>
 </p>
</div>
<div id="header2">
<p id="h2t">Executive Summary</p>
</div>
</div>
<div id="executive">
<div id="sh"><p id="sht">Executive Summary</p></div>
<div id="rich"><apex:inputTextarea richText="true" cols="100" rows="15" value="{!Work_Item__c.Executive_Summary__c}" /></div>
</div>
<div id="value">
<div id="sh"><p id="sht">Value/Business Outcomes</p></div>
<div id="rich"><apex:inputTextarea richText="true" cols="100" rows="15" value="{!Work_Item__c.Value_Measurement__c}"/> </div>
</div>
<div id="costs">
<div id="sh"><p id="sht">Ownership and Costs</p></div>
<div id="business">
<p id="h1t" style="margin-top:1em;">Accountable IT Leader :<apex:inputField value="{!Work_Item__c.Accountable_IT_Leader__c}"/> &emsp;
Work Sponsor :<apex:inputField value="{!Work_Item__c.Work_Sponsor__c}"/> </p>
<p id="h1t">Total Estimated Project Cost:&emsp;OpEx:<apex:inputField value="{!Work_Item__c.OpEx_Cost__c}"/>&ensp;
CapEx:<apex:inputField value="{!Work_Item__c.CapEx_Cost__c}"/></p>
</div>
</div>
<div id="risks">
<div id="sh"><p id="sht">Risks/Issues</p></div>
<div id="rich"><apex:inputTextarea richText="true" cols="100" rows="15" value="{!Work_Item__c.Risks_Issues__c}"/> </div>
<div id="pc">Percent Complete<apex:inputField value="{!Work_Item__c.Percent_Complete__c}"/></div>
<div id="buttons">
<apex:commandButton action="{!save}" value="Save" style="height:2.5em;width:5em;"/>&emsp;<apex:commandButton action="{!delete}"
value="Delete" style="height:2em;width:5em;" />
</div>
</div>
<div id="health">
<p id="h3t">Schedule Health<apex:inputField value="{!Work_Item__c.Schedule_Health__c}"/>&emsp;
Risk Health<apex:inputField value="{!Work_Item__c.Risk_Health__c}"/>&emsp;
Scope/QA Health<apex:inputField value="{!Work_Item__c.Quality_Scope_Health__c}"/>&emsp;
Budget Health<apex:inputField value="{!Work_Item__c.Budget_Health__c}"/></p>
</div>
<div id="status">
<div id="sh"><p id="sht">Status Summary</p></div>
<div id="srich">

<apex:inputTextarea richText="true" cols="100" rows="15" value="{!Work_Item__c.Final_Status_Summary__c}
rendered="{!IF(Work_Item__c.Percent_Complete__c==100, true, false)}"/>
<apex:inputTextarea richText="true" cols="100" rows="15" value="{!Work_Item__c.Status_Summary__c}"
rendered="{!IF(Work_Item__c.Percent_Complete__c==100, false, true)}"/>


</div>
</div>
</div>
</apex:form>
</html>
</apex:page>
VineetKumarVineetKumar
Closing quote missing for value. Check the below one
<apex:inputTextarea richText="true" cols="100" rows="15" value="{!Work_Item__c.Final_Status_Summary__c}"
rendered="{!IF(Work_Item__c.Percent_Complete__c==100, true, false)}"/>
<apex:inputTextarea richText="true" cols="100" rows="15" value="{!Work_Item__c.Status_Summary__c}"
rendered="{!IF(Work_Item__c.Percent_Complete__c==100, false, true)}"/>
This was selected as the best answer
Edwin HerreraEdwin Herrera
Sweet I did not get any errors. Thank you very much for your help with this. This has been an issue for quite some time. Allow me to check if it works properly with actual data. Thank you again
VineetKumarVineetKumar
Sure, and do remember to mark my answer as best answer, if it helped you solve your problem.