Explore Courses Blog Tutorials Interview Questions
0 votes
in Salesforce by (11.9k points)

<apex:outputField rendered="{!(WidgetType.contains('mywidget1'))}" />

When I do this I get an error...
Error: Unknown function WidgetType.contains. Check spelling
... even though the WidgetType returns a String!
It will let me do this though...
rendered="{!(WidgetType == 'mywidget1')}"
Here is the property in the controller...
public String getWidgetType() {
    return Settings.getWidgetType();

1 Answer

0 votes
by (32.1k points)
edited by


Compares two arguments of text and returns TRUE if the first argument contains the second argument. If not, returns FALSE.

The following example checks the content of a custom text field named Product_Type and returns “Parts” for any product with the word “part” in it. Otherwise, it returns “Service.” 

{!IF(contains(opportunity.Product_Type__c, "part"), "Parts", "Service")}

This function is case sensitive so be sure your compare_text value has the correct capitalization.


CONTAINS(text, compare_text) and replace text with the text that contains the value of compare_text.

Enroll in our Salesforce training to become as an Expert in Salesforce!

Browse Categories