Saturday 20 April 2024

AX365 Workflow bar is not showing in normal steps

 public static class KPFVendTableForm_Extension

{

    [FormEventHandler(formStr(VendTable), FormEventType::Initializing)]

    public static void SalesTableListPage_OnInitializing(xFormRun sender, FormEventArgs e)

    {

        FormRun                VendTableListPage         = sender;

        FormBuildDesign VendTableListPageDesign = VendTableListPage.form().design();


        VendTableListPageDesign.workflowEnabled(true);

        VendTableListPageDesign.workflowDatasource(tableStr(VendTable));

        VendTableListPageDesign.workflowType(workflowTypeStr(KPFVendorWorkflowType));

    }


    [PostHandlerFor(classStr(FormDataUtil), staticMethodStr(FormDataUtil, canSubmitToWorkflow))]

    public static void FormDataUtil_Post_canSubmitToWorkflow(XppPrePostArgs args)

    {

        Common             record               = args.getArg(identifierStr(_record));

        VendTable          salesTable           = record as VendTable;

        boolean            ret                  = args.getReturnValue();


        if (record.TableId == tableNum(VendTable))

        {

            if (salesTable.VendorStatus == KPF_ProductWorkflowBaseEnum::Draft)

            {

                ret = boolean::true;

            }

            else

            {

                ret = boolean::false;

            }

        }

        args.setReturnValue(ret);

    }


    [PostHandlerFor(formStr(VendTable), formMethodStr(VendTable, canSubmitToWorkflow))]

    public static void SalesTable_Post_canSubmitToWorkflow(XppPrePostArgs args)

    {

        FormRun salesTableDetails = args.getThis();

        formDataSource salesTableDS    = salesTableDetails.dataHelper().FindDataSource(formDataSourceStr(VendTable, VendTable));

        VendTable salesTable    = salesTableDS.cursor();

        boolean ret    = args.getReturnValue();

        if (salesTable.VendorStatus == KPF_ProductWorkflowBaseEnum::Draft)

        {

            ret = true;

        }

        else

        {

            ret = false;

        }

        args.setReturnValue(ret);

        salesTableDetails.design().controlName('WorkflowActionBarButtonGroup').visible(true);

    }


}

AX365 X++ run code after posting a sales order

 [ExtensionOf(ClassStr(SalesInvoiceJournalPost))]

final class SalesInvoiceJournalPost_Extension

{

   protected void endPost()

   {

       next endPost();

       Info(strFmt("SalesId : %1",custInvoicejour.salesId));

   }

}