Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
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

Description

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.

Use

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!

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...