WorkFlow User Names
public class DSWFDetailsUtil
{
private static DSWFDetailsUtil wFDetailsUtilObj;
public static DSWFDetailsUtil construct()
{
return (wFDetailsUtilObj) ? wFDetailsUtilObj : new DSWFDetailsUtil();
}
public Name getSubmittedBy(TableId _tableId, RecId _recId)
{
UserInfo userInfo;
WorkflowTrackingTable workflowTrackingTable;
WorkflowTrackingStatusTable workflowTrackingStatusTable;
select firstonly1 Name
from userInfo
order by workflowTrackingTable.CreatedDateTime desc
exists join workflowTrackingTable
exists join workflowTrackingStatusTable
where userInfo.id == workflowTrackingTable.User
&& workflowTrackingTable.WorkflowTrackingStatusTable == workflowTrackingStatusTable.RecId
&& workflowTrackingTable.TrackingType == WorkflowTrackingType::Submission
&& workflowTrackingStatusTable.ContextTableId == _tableId
&& workflowTrackingStatusTable.ContextRecId == _recId;
return userInfo.Name;
}
public CreatedDateTime getSubmittedDateTime(TableId _tableId, RecId _recId)
{
WorkflowTrackingTable workflowTrackingTable;
WorkflowTrackingStatusTable workflowTrackingStatusTable;
select firstonly1 CreatedDateTime
from workflowTrackingTable
order by workflowTrackingTable.CreatedDateTime desc
exists join workflowTrackingStatusTable
where workflowTrackingTable.WorkflowTrackingStatusTable == workflowTrackingStatusTable.RecId
&& workflowTrackingTable.TrackingType == WorkflowTrackingType::Submission
&& workflowTrackingStatusTable.ContextTableId == _tableId
&& workflowTrackingStatusTable.ContextRecId == _recId;
return workflowTrackingTable.CreatedDateTime;
}
// If workflow is completed then get last approver
public Name getLastApprover(TableId _tableId, RecId _recId)
{
UserInfo userInfo;
WorkflowTrackingTable workflowTrackingTable;
WorkflowTrackingStatusTable workflowTrackingStatusTable;
select firstonly1 Name
from userInfo
order by workflowTrackingTable.CreatedDateTime desc
join workflowTrackingTable
join workflowTrackingStatusTable
where userInfo.id == workflowTrackingTable.User
&& workflowTrackingTable.WorkflowTrackingStatusTable == workflowTrackingStatusTable.RecId
&& workflowTrackingTable.TrackingType == WorkflowTrackingType::Approval
&& workflowTrackingStatusTable.TrackingStatus == WorkflowTrackingStatus::Completed
&& workflowTrackingStatusTable.ContextTableId == _tableId
&& workflowTrackingStatusTable.ContextRecId == _recId;
return userInfo.Name;
}
public str getApprovedByExcludingLastApproverFormatted(TableId _tableId, RecId _recId)
{
return strReplace(con2Str(list2Con(this.getApprovedByExcludingLastApprover(_tableId, _recId))), ',', '\n');
}
public List getApprovedByExcludingLastApprover(TableId _tableId, RecId _recId)
{
UserInfo userInfo;
WorkflowTrackingTable workflowTrackingTable;
WorkflowTrackingCommentTable workflowTable;
WorkflowTrackingStatusTable workflowTrackingStatusTable;
List approvers = new List(Types::String);
// For Active / Latest workflow in case multiple workflow on single document
select firstonly workflowTrackingStatusTable
order by InstanceNumber desc
where workflowTrackingStatusTable.ContextRecId == _recId
&& workflowTrackingStatusTable.ContextTableId == _tableId;
while select Name
from userInfo
join workflowTrackingTable
where userInfo.id == workflowTrackingTable.User
&& workflowTrackingTable.TrackingType == WorkflowTrackingType::Approval
&& workflowTrackingTable.WorkflowTrackingStatusTable == workflowTrackingStatusTable.RecId
{
approvers.addEnd(userInfo.Name);
}
// If workflow is completed then remove last approver from the list
if(workflowTrackingStatusTable.TrackingStatus == WorkflowTrackingStatus::Completed && approvers.elements() > 0)
{
List newApprovers = new List(Types::String);
ListEnumerator enumerator = approvers.getEnumerator();
int length = approvers.elements();
for(int i = 0 ; i < length-1; i++)
{
enumerator.moveNext();
newApprovers.addEnd(enumerator.current());
}
approvers = newApprovers;
}
return approvers;
}
public WorkflowTrackingTable getworkflowSubmitterNameDate(TableId _tableID, RecId _recID)
{
WorkflowTrackingTable _workflowTrackingTable;
WorkflowTrackingStatusTable _workflowTrackingStatusTable;
container _workflowContainer;
select * from _workflowTrackingTable
order by _workflowTrackingTable.RecId desc
exists join Originator,CreatedDateTime from _workflowTrackingStatusTable
where _workflowTrackingTable.WorkflowTrackingStatusTable == _workflowTrackingStatusTable.RecId
&& _workflowTrackingStatusTable.ContextRecId == _recID
&& _workflowTrackingStatusTable.ContextTableId == _tableID
&& _workflowTrackingTable.TrackingType == WorkflowTrackingType::Submission;
return _workflowTrackingTable;
//_purchaseOrderHeader.ALF_OrdererName = HcmWorker::find(DirPersonUserEx::findUserWorkerReference(_workflowTrackingTable.User)).name();
//_purchaseOrderHeader.ALF_SubmissionDate = DateTimeUtil::date(_workflowTrackingTable.CreatedDateTime);
}
public List getworkflowReviewedDate(TableId _tableID, RecId _recID)
{
WorkflowTrackingTable _workflowTrackingTable;
WorkflowTrackingStatusTable _workflowTrackingStatusTable;
List reviewers = new List(Types::Date);
while select * from _workflowTrackingTable
join _workflowTrackingStatusTable where _workflowTrackingTable.WorkflowTrackingStatusTable == _workflowTrackingStatusTable.RecId
&& _workflowTrackingTable.TrackingType == WorkflowTrackingType::Approval
&& (_workflowTrackingTable.TrackingContext == WorkflowTrackingContext::Approval || _workflowTrackingTable.TrackingContext == WorkflowTrackingContext::WorkItem)
&& _workflowTrackingStatusTable.ContextTableId == _tableID
&& _workflowTrackingStatusTable.ContextRecId == _recID
&& _workflowTrackingStatusTable.ContextCompanyId == curExt()
{
reviewers.addEnd(DateTimeUtil::date(_workflowTrackingTable.CreatedDateTime));
}
return reviewers;
}
public List getworkflowApproverName(TableId _tableID, RecId _recID)
{
WorkflowTrackingTable _workflowTrackingTable;
WorkflowTrackingCommentTable _workflowTable;
WorkflowTrackingStatusTable _workflowTrackingStatusTable, _workflowLastStatus;
container _workflowContainer;
List approvers = new List(Types::String);
int approverIndex = 0;
select firstonly _workflowLastStatus order by InstanceNumber desc where _workflowLastStatus.ContextRecId == _recID
&& _workflowLastStatus.ContextTableId == _tableID;
//info(_workflowLastStatus.InstanceNumber);
while select * from _workflowTrackingTable
join _workflowTrackingStatusTable where _workflowTrackingTable.WorkflowTrackingStatusTable == _workflowLastStatus.RecId
&& _workflowTrackingTable.TrackingType == WorkflowTrackingType::Approval
&& (_workflowTrackingTable.TrackingContext == WorkflowTrackingContext::Approval || _workflowTrackingTable.TrackingContext == WorkflowTrackingContext::WorkItem)
&& _workflowTrackingStatusTable.ContextTableId == _workflowLastStatus.ContextTableId
&& _workflowTrackingStatusTable.ContextRecId == _workflowLastStatus.ContextRecId
&& _workflowTrackingStatusTable.ContextCompanyId == curExt()
&& _workflowTrackingStatusTable.InstanceNumber == _workflowLastStatus.InstanceNumber
{
approvers.addEnd(HcmWorker::find(DirPersonUserEx::findUserWorkerReference(_workflowTrackingTable.User)).name());
}
return approvers;
}
}
Comments
Post a Comment