Friday, May 24, 2019

X++ code to return Workflow approver name

Method to return value of last approver :


public Name workflowApprover(RecId _recId)
        {
            WorkflowTrackingStatusTable workflowTrackingStatus;
            WorkflowTrackingTable workflowTrackingTable;
            WorkflowTrackingCommentTable workflowTrackingCommentTable;
            UserInfo userInfo;
       
            select firstFast RecId, User from workflowTrackingTable
                order by RecId desc
            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(CICGBCreditCommittal)// your custom table on which workflow is enabled.
            && workflowTrackingTable.TrackingType == WorkflowTrackingType::Approval;
       
            if (workflowTrackingTable.RecId > 0)
            {
                return userInfo.name;
            }
            else
            {
                return '';
            }
       
        }

=======================================================================

Display method for the same :


display Name displayWorkflowApproverName()
{
    WorkflowTrackingStatusTable     workflowTrackingStatus;
    WorkflowTrackingTable           workflowTrackingTable;
    WorkflowTrackingCommentTable    workflowTrackingCommentTable;
    UserInfo                        userInfo;
    Name                            _name;


    select firstFast RecId, User from workflowTrackingTable
        order by RecId desc
            join workflowTrackingCommentTable
        where workflowTrackingCommentTable.WorkflowTrackingTable == workflowTrackingTable.RecId
            join UserInfo
        where UserInfo.id == WorkflowTrackingTable.User
            exists join workflowTrackingStatus
        where workflowTrackingTable.WorkflowTrackingStatusTable == workflowTrackingStatus.RecId
    && workflowTrackingStatus.ContextRecId      == this.RecId
    && workflowTrackingStatus.ContextTableId    == tableNum(CICGBCreditCommittal)
    && workflowTrackingTable.TrackingType       == WorkflowTrackingType::Approval;

    if (workflowTrackingTable.RecId > 0)
    {
        _name=userInfo.name;
    }

    else
    {
        _name='';
    }
    return _name;
}

1 comment:

  1. CasinoTopo Casino D - 100% Bonus up to €100
    CasinoTopo w88dashboard Casino D offers 100% up to €100 + 200 free 승인 전화 없는 토토 꽁 머니 spins 토토 사이트 리스트 to new players. CasinoTopo Casino also offers 300+ 실시간 바카라 table games, 50+ 슬롯 머신 게임 live dealer games and

    ReplyDelete

How to enable the dimension fields based on the Item selected on the form.

[Form] public class KMTShipFromWarehouses extends FormRun {     InventDimCtrl_Frm_EditDimensions        inventDimFormSetup;     /// ...