You need to sign in to do that
Don't have an account?
Gleb Vrevsky
Visualforce page - IF usage to compare string value for custom object
Hello!
Task: I am trying to create pretty much simple visualforce page. Table with 5 columns. Column 1 = Employee name. Column 2-5 = Employee completed courses.
Problem: Faced a problem creating columns for employee courses. These columns should output the TRUE or FALSE value e.g. if employee has completed a course or not. The current implementation looks like:
Code above is just a test, trying to make IF statement work - no luck (also tried to use CONTAINS).
Question:
What is the right way to compare custom objects values on visualforce page? Is it worth to use custom controller, and get all required data already inside the custom class, not to complicate visualforce page structure?
Task: I am trying to create pretty much simple visualforce page. Table with 5 columns. Column 1 = Employee name. Column 2-5 = Employee completed courses.
Problem: Faced a problem creating columns for employee courses. These columns should output the TRUE or FALSE value e.g. if employee has completed a course or not. The current implementation looks like:
<apex:page standardController="CourseEnrollment__c" recordSetVar="records" id="thePage" cache="false"> <apex:form id="theForm"> <apex:pageBlock id="thePageBlock"> <apex:pageBlockTable value="{!records}" var="record" id="thePageBlockTable"> <apex:column > <apex:outputField value="{!record.Employee__r.Name}" id="EmployeeNameDOM" /> <apex:facet name="header">Name</apex:facet> </apex:column> <apex:column> <apex:outputText value="{!IF(!record.Course__r.Status == 'Completed','Completed','Expected')}" id="CourseNameDOM" /> <apex:facet name="header">Course status</apex:facet> </apex:column> </apex:pageBlockTable> </apex:pageBlock> </apex:form> </apex:page>The main object is CourseEnrollment, Employee and Course are related objects (master-details relation -> http://www.screencast.com/t/nLStStlAjzr)
Code above is just a test, trying to make IF statement work - no luck (also tried to use CONTAINS).
Question:
What is the right way to compare custom objects values on visualforce page? Is it worth to use custom controller, and get all required data already inside the custom class, not to complicate visualforce page structure?
try below statement-
<apex:outputText value="{!IF(record.Course__r.Status = 'Completed','Completed','Expected')}" id="CourseNameDOM" />
Thanks,
Gaurav
All Answers
try below statement-
<apex:outputText value="{!IF(record.Course__r.Status = 'Completed','Completed','Expected')}" id="CourseNameDOM" />
Thanks,
Gaurav
That should do what you want.