Sunday, July 3, 2016

Customize X++ Workflow single approval ax 2012 R3

//Customize X++ Workflow single approval ax 2012 R3
1) Table - (Approver Name)
 Add new field approver name in Journal Master
 Display Name getJournalApprvName()
 {
     InventJournalName inventJournalName;
     select firstOnly inventJournalName where inventJournalName.JournalNameId == this.JournalNameId;
     return inventJournalName.ApproverUser;
 }
2) Table - Workflow enabling Table - Add Workflow status field
3) Form -> Method
Public void setInvtApprovalCtrlVisibility(container _con)
{
    // Group - InventApproval
    // StaticText - InventStatic
    // Button - InventSubmit
    // Menubutton - InventAction
    InventApproval.visible(conPeek(_con,1));
    InventStatic.text(conPeek(_con,2));
    InventSubmit.visible(conPeek(_con,3));
    InventAction.visible(conPeek(_con,4));
}
4) Form --> Datasource Method
 active-->
 element.setInvtApprovalCtrlVisibility(EPGE_InventJournalApproval::setVisibility(InventJournalTable_ds.cursor()));
5)
// Group visibility
// Static text
// Submit button visibility
// Action button visibility
Public static container setVisibility(Common _common)
{
    InventJournalTable      inventJournalTable;
    container               con;
    ;
    if (_common.TableId == tableNum(InventJournalTable))
    {
        inventJournalTable = _common;
    }

    if (!_common)
    {
        con = conIns(con,1,false);
        con = conIns(con,2,"");
        con = conIns(con,3,false);
        con = conIns(con,4,false);
    }
    if (inventJournalTable.InventWorkflowStatus == InventWorkflowStatus::None)
    {
        con = conIns(con,1,true);
        con = conIns(con,2,"Workflow Not yet Submitted");
        con = conIns(con,3,True);
        con = conIns(con,4,false);
    }
    else if (inventJournalTable.InventWorkflowStatus == InventWorkflowStatus::Submitted)
    {
        if(inventJournalTable.getJournalApprvName() == curUserId()
                || inventJournalTable.getJournalApprvName2() == curUserId())
        {
            con = conIns(con,1,True);
            con = conIns(con,2,"Approval is InProgress ");
            con = conIns(con,3,False);
            con = conIns(con,4,True);
        }
        else
        {
            con = conIns(con,1,True);
            con = conIns(con,2,"Workflow is Submitted to Journal Reviewer Approval User");
            con = conIns(con,3,False);
            con = conIns(con,4,False);
        }
    }
    else if (inventJournalTable.InventWorkflowStatus == InventWorkflowStatus::Approved)
    {
        con = conIns(con,1,True);
        con = conIns(con,2,strFmt("Workflow is %1.... Journal %2 for posting",inventJournalTable.InventWorkflowStatus,inventJournalTable.InventWorkflowStatus));
        con = conIns(con,3,false);
        con = conIns(con,4,false);
    }
    else if (inventJournalTable.InventWorkflowStatus == InventWorkflowStatus::Rejected)
    {
        con = conIns(con,1,True);
        con = conIns(con,2,strFmt("Workflow is %1.... Journal %2 for posting, Workflow can Submit Again",inventJournalTable.InventWorkflowStatus,inventJournalTable.InventWorkflowStatus));
        con = conIns(con,3,True);
        con = conIns(con,4,False);
    }
    return con;
}

No comments:

Post a Comment

Copy Markup charges while posting purchase invoice using X++

 Copy Markup charges while posting purchase invoice using X++ Class: Important: Code logic is just for Reference.  New class => Duplicate...