0
votes

Would someone be able to help me with two questions;

I am writing a simple VisualForce page to display some key record information on lightning page for our sales manager to know their email address health.  Currently I have the following code:

<apex:page standardController="Contact"> <p style="font-size:20px">This is where we will place information on the email health status</p> <p style="font-size:14px"> Record Source: <apex:outputField value="{!Contact.Record_Source2__c}"/> <br/> Email Opt Out: <apex:outputField value="{!Contact.HasOptedOutOfEmail}"/> <br/> Email Opt In:<br/> Email Error: <apex:outputField value="{!Contact.Email_Error__c}"/> <br/> Last Modified: <apex:outputField value="{!Contact.LastCURequestDate}"/> </p> </apex:page> 

Questions 1)  If I want to display the last modified date, how would I pull this data?

  1. How can I make the text for Email Opt Out: display in RED if the customer has opt-out "True".

​​​​​​​Suggestions?

1

1 Answers

0
votes

Questions 1) If I want to display the last modified date, how would I pull this data?

Just add this line: <br/>Last Modified Date: <apex:outputField value="{!Contact.LastModifiedDate}"/>

How can I make the text for Email Opt Out: display in RED if the customer has opt-out "True".

Here's a list of functions you could use in a Visualforce expression.
The one you're looking for is: IF(logical_test, value_if_true, value_if_false).
You could use it to add a style (i.e. color: red;) to a span element.

The visualforce page should look like:

<apex:page standardController="Contact">
    <p style="font-size:20px">This is where we will place information on the email health status</p>
    <p style="font-size:14px">Record Source: <apex:outputField value="{!Contact.Record_Source2__c}"/>
        <br/><span style="{!IF(Contact.HasOptedOutOfEmail, 'color: red;', 'color: black;')}">Email Opt Out</span>: <apex:outputField value="{!Contact.HasOptedOutOfEmail}"/>
        <br/>Email Opt In:
        <br/>Email Error: <apex:outputField value="{!Contact.Email_Error__c}"/>
        <br/>Last Modified: <apex:outputField value="{!Contact.LastCURequestDate}"/>
        <br/>Last Modified Date: <apex:outputField value="{!Contact.LastModifiedDate}"/>
    </p>
</apex:page>