Showing posts with label History related lists in visual force. Show all posts
Showing posts with label History related lists in visual force. Show all posts

Friday, June 1, 2012

History related lists in visual force


Issue – To display the History related lists in visual force
Solution – We can make use of the standard history relationship to display the history related lists in visual force without controller.

Code: To display the Account History Related lists,

<apex: page standard Controller=”Accounts”>

<!—Displays Accounts History Related lists -- >

<apex:dataTable value="{!Account.histories}" var="accountHistory" width="100%">

                 <!—Displays Created Date of the Field History -- >

                <apex:column>

                                <apex:facet name="header">Date</apex:facet>

                                <apex:outputText value="{0,date,MM/dd/yyyy HH:mm }">

                                                <apex:param value="{!accountHistory.createddate}" />

                                </apex:outputText>

               </apex:column>

              <!—Displays the corresponding field -- >

              <apex:column >

                 <apex:facet name="header">Field</apex:facet>

                                 <b> <apex:outputText  value="{!IF(CONTAINS(accountHistory.field,'__c'),LEFT(accountHistory.field, LEN(accountHistory.field) -3),accountHistory.field)}"/></b>

            </apex:column>

            <!—Displays Edited By User-- >                        

            <apex:column >

                <apex:facet name="header">Edited By</apex:facet>

                <apex:outputText value="{!accountHistory.createdby.name}"/>

            </apex:column>

            <!—Displays Old value of the field -- >

            <apex:column >

                <apex:facet name="header">Old Value</apex:facet>

                <apex:outputText value="{!accountHistory.oldvalue}"/>

            </apex:column>

            <!—Displays New Value of the field -- >

            <apex:column >

                <apex:facet name="header">New Value</apex:facet>

                <apex:outputText value="{!accountHistory.newvalue}"/>

            </apex:column>

        </apex:datatable>

    </apex:pageblock>   

</apex:page>


Issue – To display the HelpText for a field in visualforce
Solution: We can make use of “inlineHelpText” to display the helptext of a field in visualforce
Sample Code: To display the Help Text for Account Industry field,

    <apex:outputText value=” {!$ObjectType.Account.Fields.Industry.inlineHelpText}"/>