I have some conditionals in my Visualforce page (that will turn into a PDF) but it does not seem to understand the person variable or the .includes() function. Is this because formula can not read the apex:repeat?


public User [] hilightName {get;set;}
hilightName = [SELECT Manager.Name FROM User];


<apex:repeat value="{!allPeople}" var="person">
    <td style="{!IF(person.Name == person.Manager.Name,'background-color: #F78D2C', '')}">{!person.Name}</td> 
    <!--<td style="{!IF(hilightName.includes(person.Name),'background-color: #F78D2C', '')}">{!person.Name}</td>--> 

UPDATE: I was using contains/includes wrong.

<td style="{!IF(contains(person.Name,person.Manager.Name),'background-color: #efefef', '')}">{!person.Name}</td>
  • That's no JavaScript, it's a Visualforce formula.
    – sfdcfox
    Jan 23 '17 at 17:04
  • @sfdcfox thank you for the correct naming. I just always call it inline conditionals which makes me think of JavaScript. I updated the question title.
    – Olivia
    Jan 23 '17 at 17:05

includes function of String class is available in Javascript.

var str = "Hello world, welcome to the universe.";
var n = str.includes("world"); 

In Visualforce <apex:repeat/> in that <td/> use formula expression like


For more information, refer Functions

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.