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
Pablo Rivera 7Pablo Rivera 7 

Single Code Error Syntax

Trying conditional formatting setting Apex Class. Used following code:

public class Hl{
 <apex:pageBlockSection>
    <apex:outputField value={!Response_Time__c}
    style={!IF(Response_Time__c > 3, 'color:red;', '')} />
            </apex:pageBlockSection> 
                }
}

Problem is I am getting syntax error "Line 1 Unexpected token '{'." Can't figure out what the issue is. 
SwethaSwetha (Salesforce Developers) 
HI Pablo,

You cannot have an apex:pageBlockSection component directly inside an apex class. These are used on VF pages

Your code should look something like below
Apex class:
public class HI {
    public PageReference getPageReference() {
        PageReference pageRef = new PageReference('/apex/MyPage');
        return pageRef;
    }
}

VF page named MyPage:
<apex:page controller="HI">
    <apex:pageBlock>
        <apex:pageBlockSection>
            <apex:outputField value="{!Response_Time__c}" style="{!IF(Response_Time__c > 3, 'color:red;', '')}" />
        </apex:pageBlockSection>
    </apex:pageBlock>
</apex:page>
Related: https://trailhead.salesforce.com/content/learn/modules/visualforce_fundamentals/visualforce_custom_controllers

If this information helps, please mark the answer as best. Thank you
Pablo Rivera 7Pablo Rivera 7
Thank you. Getting this error now: Could not resolve the entity from <apex:outputField> value binding '{!Response_Time__c}'.  <apex:outputField> can only be used with SObjects, or objects that are Visualforce field component resolvable. Sounds like I cannot use a custom object only standard object?
SwethaSwetha (Salesforce Developers) 
HI Pablo,
The code you provided does not show where the {!Response_Time__c} field is defined or what object it belongs to. I'm afraid we cannot move forward without the complete picture about the custom object and its fields, as well as the full code for the controller and Visualforce page

Recommend reviewing https://salesforce.stackexchange.com/questions/301162/could-not-resolve-the-entity-from-apexinputfield-value-binding-firstname

https://salesforce.stackexchange.com/questions/310357/error-could-not-resolve-the-entity-from-value-binding

If this information helps, please mark the answer as best. Thank you