I'm trying to display history of action performed on custom object 'Reservation' in VisualForce page in table using apex:pageBlockTable.
I have following method in controller:
public List<Reservation__History> getReservationHistory()
{
Reservation__c rsv= (Reservation__c)currentcontroller.getRecord();
List<Reservation__History> history = [SELECT ParentId, OldValue, NewValue, Field, CreatedById, CreatedDate FROM Reservation__History WHERE parentId = : rsv.Id ORDER BY CreatedDate DESC];
return history;
}
And I'm calling this method in apex:pageBlockTable as follows:
<apex:pageBlockTable value="{!ReservationHistory}" var="history">
<apex:column headerValue="Date" value="{!history.CreatedDate}"/>
<apex:column headerValue="User" value="{!history.CreatedById}"/>
<apex:column headerValue="Action" value="!IF(history.OldValue='' AND history.NewValue='', 'Created', Changed '{!history.Field}' from '{!history.OldValue}' to '{!history.NewValue}')"/>
</apex:pageBlockTable>
For "Action" column, if condition I tried above is not working. I want to display Action as 'Created' if both OldValue and NewValue are '' else display a sentence "Changed '{!history.Field}' from '{!history.OldValue}' to '{!history.NewValue}'".
Can anybody please let me know how to conditionally vary content in 'value' of apex:column for above scenario?