You need to sign in to do that
Don't have an account?
Edwin Herrera
Variables inside IF ELSE
Hi Everyone,
The 3 variables I am dealing with are Final_Status_Summary__c, Status_Summary__c and Percent_Complete__c. I would like to display final status summary if percent complete is 100 otherwise display status summary on my page.
The 3 variables I am dealing with are Final_Status_Summary__c, Status_Summary__c and Percent_Complete__c. I would like to display final status summary if percent complete is 100 otherwise display status summary on my page.
<apex:inputTextarea richText="true" cols="100" rows="16" 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="16" value="{!Work_Item__c.Status_Summary__c}"
rendered="{!IF(Work_Item__c.Percent_Complete__c==100, false, true)}"/>
All Answers
You need to create a formulae field for showing the status : The formulae would be something like below
Let me know if this helps.
With this code I am getting this error.
Error: Attribute value in <apex:inputField> must contain only a formula expression that resolves to a single controller variable or method
This is the following code line I have built up to. Earlier I had this.
{!IF(Work_Item__c.Percent_Complete__c == 100,"{!Work_Item__c.Final_Status_Summary__c}", "{!Work_Item__c.Status_Summary__c}")}
This code was outputting this on the page. {!Work_Item__c.Status_Summary__c}
Error: Syntax error. Missing ')'.
There definitely is a close parentheses before the close bracket. Not sure what is causing it. I also made sure if the rest of the code is causing it, but it is not.
Looks like Work_Item__c is an object, infact it should be an instance of object.
<style>
body{background-color:white;}
h1
{
text-align:center;
}
</style>
<h1>Project Executice Summary</h1>
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection columns="2" title="Work Item Details">
<apex:inputField value="{!Work_Item__c.Name}"/>
<apex:inputField value="{!Work_Item__c.Work_Item_ID__c}"/>
<apex:inputField value="{!Work_Item__c.Accountable_IT_Leader__c}"/>
<apex:inputField value="{!Work_Item__c.Work_Sponsor__c}"/>
<apex:inputField value="{!Work_Item__c.Forecasted_Finish__c}"/>
<apex:inputField value="{!Work_Item__c.Actual_Finished__c}"/>
<apex:inputField value="{!Work_Item__c.Percent_Complete__c}"/>
<apex:inputField value="{!Work_Item__c.LSEF_Stage_del__c}"/>
</apex:pageBlockSection>
<apex:pageblockSection title="Summary Indicators" columns="3">
<apex:inputField value="{!Work_Item__c.Status_as_of__c}"/>
<apex:inputField value="{!Work_Item__c.Overall_Health__c}"/>
<apex:inputField value="{!Work_Item__c.Quality_Scope_Health__c}"/>
<apex:inputField value="{!Work_Item__c.Schedule_Health__c}"/>
<apex:inputField value="{!Work_Item__c.Risk_Health__c}"/>
<apex:inputField value="{!Work_Item__c.Risks_Issues__c}"/>
<apex:inputField value="{!IF(Work_Item__c.Percent_Complete__c == 100, Work_Item__c.Final_Status_Summary__c, Work_Item__c.Status_Summary__c)}"/>
</apex:pageblockSection>
<apex:pageblockSection title="Project Costs">
<apex:inputField value="{!Work_Item__c.OpEx_Cost__c}"/>
<apex:inputField value="{!Work_Item__c.CapEx_Cost__c}"/>
</apex:pageblockSection>
<apex:pageBlockSection title="Report">
<apex:inputField value="{!Work_Item__c.Executive_Summary__c}"/>
<apex:inputField value="{!Work_Item__c.Value_Business_Outcomes__c}"/>
<apex:inputField value="{!Work_Item__c.Value_Measurement__c}"/>
</apex:pageBlockSection>
<apex:commandButton value="Save"/>
<apex:commandButton value="Delete"/>
</apex:pageBlock>
</apex:form>
</apex:page>
You cannot use IF condition in inputField tag
Since you said you just want to display the value on the page.
Please use the output tag
Error: WIP_STaRT line 31, column 18: Element type "apex:outputText" must be followed by either attribute specifications, ">" or "/>"
Error: Element type "apex:outputText" must be followed by either attribute specifications, ">" or "/>".
Let me know if this helps.
Please help the community by selecting the best answer right under the comment, if my solution help you.
Should anyone facing similar issue may get the solution
<apex:inputTextarea richText="true" cols="100" rows="16" 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="16" value="{!Work_Item__c.Status_Summary__c}"
rendered="{!IF(Work_Item__c.Percent_Complete__c==100, false, true)}"/>