Workflow last approver by using po recId

 public UserId getWFLastApprover(PurchPurchaseOrderHeader _purchaseOrderHeader)

    {

        WorkflowTrackingTable           workflowTrackingTable;

        WorkflowTrackingStatusTable     workflowTrackingStatusTable;


        PurchTable purchTable =  PurchTable::find(_purchaseOrderHeader.PurchId);


        select firstonly RecId from workflowTrackingStatusTable

            where

                workflowTrackingStatusTable.ContextTableId      == purchTable.TableId

               && workflowTrackingStatusTable.ContextRecId        == purchTable.RecId

            join firstonly user from workflowTrackingTable order by CreatedDateTime desc

            where workflowTrackingTable.WorkflowTrackingStatusTable == workflowTrackingStatusTable.RecId

            &&    (workflowTrackingTable.TrackingType == WorkflowTrackingType::Approval   ||

            workflowTrackingTable.TrackingType == WorkflowTrackingType::Completion)

            &&    workflowTrackingTable.TrackingContext == WorkflowTrackingContext::WorkItem;


        if(!workflowTrackingTable.User)

        {


        PurchReqTable purchReq = PurchReqTable::findPurchReqId(_purchaseOrderHeader.CMCPurchReqId);


        select firstonly RecId from workflowTrackingStatusTable

            where

                workflowTrackingStatusTable.ContextTableId      == purchReq.TableId

               && workflowTrackingStatusTable.ContextRecId        == purchReq.RecId

            join firstonly user from workflowTrackingTable order by CreatedDateTime desc

            where workflowTrackingTable.WorkflowTrackingStatusTable == workflowTrackingStatusTable.RecId

            &&(workflowTrackingTable.TrackingType == WorkflowTrackingType::Approval   ||

            workflowTrackingTable.TrackingType == WorkflowTrackingType::Completion)

            &&    workflowTrackingTable.TrackingContext == WorkflowTrackingContext::WorkItem;

        }


        return workflowTrackingTable.User;

    }

Comments

Popular posts from this blog

Logistics address, postal address, address phone fax contact information

Ledger dimensions and financial Dimensions X++

Prepay posting vendor invoice with amounts