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
Carla CookCarla Cook 

How can I build a selectList with selectOption based on field content?

How can I build a selectList with selectOption based on field content?  And, in general,  how can IF's be added to Visual Force code?

<apex:selectList >
If RecordType.Name contains Hiring,  I'd like TWO selectOption statements,  if Name does not contain Hiring,  I'd like a different selectOption statement.

When I execute the code below, ALL three selectOption statements execute every time.
Here's the code....
<apex:selectList> 

{ !IF (CONTAINS ({!Engagement__c.RecordType.Name},"Hiring"), <apex:selectOption itemLabel="Initial Contact for Hiring Need" itemValue="Initial Contact"/>
<apex:selectOption itemLabel="Follow-up Contact for Hiring Need" itemValue="Followup Contact"/>,
<apex:selectOption itemLabel="NOT Hiring Need" itemValue="NOT Hiring Need"/> ) }
</apex:selectList> 
 
Vivek DVivek D
Inside formula you don't need to include the markups for the fields, make the correction here 
{!IF (CONTAINS (Engagement__c.RecordType.Name, "Hiring" ), .....  })