Thursday, July 30, 2026

WorkFlow

My requirement is to validate the data before submitting the workflow. Currently, the validation error message is displayed in the workflow dialog, but I need it to be displayed on the master form before the workflow submission dialog opens.


public class WorkflowSubmitManager

{

    WorkflowComment      workflowComment;

    WorkflowVersionTable workflowVersionTable;

    boolean              bypassDialog;

    boolean              canceledAction;


    #define.BypassDialog('BypassDialog')


    public static WorkflowSubmitManager construct()

    {

        return new WorkflowSubmitManager();

    }


    public WorkflowComment parmWorkflowComment(

        WorkflowComment _workflowComment = workflowComment)

    {

        workflowComment = _workflowComment;

        return workflowComment;

    }


    public boolean parmBypassDialog(boolean _bypassDialog = bypassDialog)

    {

        bypassDialog = _bypassDialog;

        return bypassDialog;

    }


    public boolean parmCanceledAction(boolean _canceledAction = canceledAction)

    {

        canceledAction = _canceledAction;

        return canceledAction;

    }


    public boolean dialogOk(boolean _ok = false)

    {

        WorkflowSubmitDialog workflowSubmitDialog;


        if (!_ok)

        {

            workflowSubmitDialog = WorkflowSubmitDialog::construct(workflowVersionTable);

            workflowSubmitDialog.run();


            if (workflowSubmitDialog.parmIsClosedOK())

            {

                _ok = true;

                workflowComment = workflowSubmitDialog.parmWorkflowComment();

            }

            else

            {

                canceledAction = true;

            }

        }


        return _ok;

    }


    public boolean submitToWorkflow(Args _args)

    {

        Common callerRecord = _args.record();


        workflowVersionTable = Workflow::findWorkflowConfigToActivateForType(

            workFlowTypeStr(YourWorkflowType),

            callerRecord.RecId,

            callerRecord.TableId);


        Debug::assert(workflowVersionTable.RecId != 0);


        str callerParm = _args.parm();


        if (callerParm == #BypassDialog)

        {

            this.parmBypassDialog(true);

        }


        this.parmCanceledAction(false);


        if (this.dialogOk(bypassDialog))

        {

            Workflow::activateFromWorkflowConfigurationId(

                workflowVersionTable.ConfigurationId,

                callerRecord.RecId,

                this.parmWorkflowComment(),

                NoYes::No);

        }


        return true;

    }

No comments:

Post a Comment

Purchase Orders

 Before confirming a Purchase Order, the system should display a confirmation popup if the purchase order is associated with an active inter...