For First Approver,
this.workflowApprover(purchReqTable.RecId);
public void workflowApprover(RecId _recId) // Requsation Table RecId
{
WorkflowTrackingStatusTable workflowTrackingStatus;
WorkflowTrackingTable workflowTrackingTable;
WorkflowTrackingCommentTable workflowTrackingCommentTable;
UserInfo userInfo;
select firstFast RecId, User from workflowTrackingTable
order by RecId asc
join workflowTrackingCommentTable
where workflowTrackingCommentTable.WorkflowTrackingTable == workflowTrackingTable.RecId
join UserInfo
where UserInfo.id == WorkflowTrackingTable.User
exists join workflowTrackingStatus
where workflowTrackingTable.WorkflowTrackingStatusTable == workflowTrackingStatus.RecId
&& workflowTrackingStatus.ContextRecId == _recId
&& workflowTrackingStatus.ContextTableId == tableNum(PurchReqTable)// your custom table on which workflow is enabled.
&& workflowTrackingTable.TrackingType == WorkflowTrackingType::Approval;
if (workflowTrackingTable.RecId > 0)
{
S3_PurchTable_Tmp.RecommendedBy = userInfo.name;
S3_PurchTable_Tmp.Designation_Recommended = hcmworker::findByPerson(DirPersonUser::find(userInfo.id).PersonParty).title();
S3_PurchTable_Tmp.RecommendedId = hcmworker::findByPerson(DirPersonUser::find(userInfo.id).PersonParty).PersonnelNumber;
}
}
For Last Approver,
this.workflowApprover_last(purchReqTable.RecId);
public void workflowApprover_last(RecId _recId)
{
WorkflowTrackingStatusTable workflowTrackingStatus;
WorkflowTrackingTable workflowTrackingTable;
WorkflowTrackingCommentTable workflowTrackingCommentTable;
UserInfo userInfo;
while select RecId, User from workflowTrackingTable
order by RecId asc
join workflowTrackingCommentTable
where workflowTrackingCommentTable.WorkflowTrackingTable == workflowTrackingTable.RecId
join UserInfo
where UserInfo.id == WorkflowTrackingTable.User
exists join workflowTrackingStatus
where workflowTrackingTable.WorkflowTrackingStatusTable == workflowTrackingStatus.RecId
&& workflowTrackingStatus.ContextRecId == _recId
&& workflowTrackingStatus.ContextTableId == tableNum(PurchReqTable)// your custom table on which workflow is enabled.
&& workflowTrackingTable.TrackingType == WorkflowTrackingType::Approval
{
if (workflowTrackingTable.RecId > 0)
{
S3_PurchTable_Tmp.ApprovedBy = userInfo.name;
S3_PurchTable_Tmp.Designation_Approved = hcmworker::findByPerson(DirPersonUser::find(userInfo.id).PersonParty).title();
S3_PurchTable_Tmp.ApproverId = hcmworker::findByPerson(DirPersonUser::find(userInfo.id).PersonParty).PersonnelNumber;
}
}
}
No comments:
Post a Comment