I have added the display method on tbale level and then use it on form, I have also passed the table name on display method
code is : public display str pendingapprovalname(RequestTable _RequestTable)
{
WorkflowTrackingStatusTable workflowTrackingStatusTable;
WorkflowTrackingTable workflowTrackingTable;
WorkflowWorkItemTable workitem;
select workitem where workitem.RefRecId == _RequestTable.Recid
&& workitem.RefTableId == _PTPTORequestTable.TableId
&& workitem.Status == WorkflowWorkItemStatus::Pending
join WorkflowTrackingStatusTable
where WorkflowTrackingStatusTable.CorrelationId == workitem.CorrelationId
join workflowTrackingTable order by RecId desc
where workflowTrackingTable.WorkflowTrackingStatusTable == workflowTrackingStatusTable.RecId
&& workflowTrackingTable.TrackingContext == WorkflowTrackingContext::Step;
return workflowTrackingTable.Name;
}
using the above disply method in form where workflow is enable.