Skip to main content

CREATION OF CUSTOMIZED WORKFLOW


CREATION OF CUSTOMIZED WORKFLOW

Requirement:
Let’s say we have students in the system. Some of the students are blocked due to overdue semester fees. System should be able to allow user to submit such students to a workflow process for approval to a super user e.g. Principal. Once the Principal approves such students only then students should be allowed to take more courses in the next semester.
Development:
1. Create a Workflow state Enum to have the following elements:
  • NotSubmitted
  • Submitted
  • Approved
  • Rejected
2. Add field of type Workflow state enum to the custom table FAZStudentTable.
3. Override canSubmitToWorkflow() method of the custom table to define Workflow submission criteria.

public boolean canSubmitToWorkflow(str _workflowType = '')
{
    boolean ret = false;

    if (this.Blocked == NoYes::Yes)
        ret = true;

    return ret;
}

4. Create a Query for the custom table.
5. Create a Workflow Category.
6. Create a Workflow Type using wizard.
Untitled
where,
  • Category – Name of the Workflow category just created.
  • Query – Name of the query just created.
  • Document menu item – Name of display menu item for the form to enable Workflow on.
The following artifacts will be created:
  • Workflow Type
  • Classes
    • Document class which extends WorkflowDocument.
    • EventHandler class which gives implementation to handle different workflow events.
    • SubmitManager class.
  • Action menu items:
    • SubmitMenuItem pointing to SubmitManager class.
    • CancelMenuItem pointing to WorkflowCancelManager class.
7. Enable Workflow on the custom form FAZStudentTable by setting Design node properties as follows:
  • WorkflowEnabled – Yes.
  • WorkflowDatasource – Name of the form Datasource.
  • WorkflowType – Name of the custom Workflow Type just created.
8. Give submit logic in SubmitManager class.

public static void main(Args _args)
{
    FAZStudentTableSubmitManager    submitManager;

    submitManager = new FAZStudentTableSubmitManager();
    submitManager.submit(_args);
}
public void submit(Args _args)
{
    FAZStudentTable         studentTable;
    WorkflowComment         note = "";
    WorkflowSubmitDialog    workflowSubmitDialog;

    //Opens the submit to workflow dialog.
    workflowSubmitDialog = WorkflowSubmitDialog::construct(
        _args.caller().getActiveWorkflowConfiguration());
    workflowSubmitDialog.run();

    if (workflowSubmitDialog.parmIsClosedOK())
    {
        studentTable = _args.record();
        // Get comments from the submit to workflow dialog.
        note = workflowSubmitDialog.parmWorkflowComment();

        try
        {
            ttsbegin;
            studentTable.WorkflowStatus = MAKWorkflowStatus::Submitted;
            ttscommit;

            // Send an Infolog message.
            info("Submitted to workflow.");
        }
        catch (Exception::Error)
        {
            error("Error on workflow activation.");
        }
    }

    _args.caller().updateWorkFlowControls();
}

9. Create a Workflow Approval using the wizard.
10. Drag the newly created Approval to the Supported elements node of the custom Workflow Type.
11. Design the Workflow.
  • Create display menu item pointing to WorkflowTableListPage form.
  • On Properties sheet of the display menu item
    • Set EnumTypeParameter to ModuleAxapta.
    • Set EnumParameter to Basic.
  • Drag this menu item to the Setup subMenu of area page of the desired AX module.
  • On Properties sheet of the menu item
    • Set IsDisplayedInContentArea to Yes.
  • Navigate to the menu item to open WorkflowTableListPage to design the workflow.
  • Create a new workflow instance of the Workflow Type you created.
  • Define the states from Start to Endof the workflow.
    • Drag approval element from Toolbox on the left to the Designer pane on the right.
    • Connect the bottom of Start state with top of the Approval element.
    • Connect the bottom of Approval element to the top of End state.
  • Resolve any errors and warnings by setting workflow and approval element properties.
  • Activate it.
Untitled
12. Test the workflow.
  • Update records in the FAZStudentTable to meet the submission criteria of the workflow e.g. block one of the records in DB
  • Navigate to the form FAZStudentTable enabled for the custom workflow.
  • You can see in the picture below, selecting the particular record, the system allows user to submit student to the custom workflow created :)

Comments

Popular posts from this blog

D365 : ENABLE AND DISABLE IN LIST PAGE

 here i have added 4 button in salesQuotationlistpage. now i need to enable/disable button according status. so i have Extensionof  of class SalesQuotationListPageInteraction and modify setButtonEnabled method by Chain of Command //list page button enable and diable in listpage interation class [ExtensionOf(classStr(SalesQuotationListPageInteraction))] final class SQTableinimathod_Extension {     protected void setButtonEnabled()     {                SalesQuotationTable SalesQuotationTable;         CustQuotationJour   CustQuotationJour;         CustQuotationConfirmJour  CustQuotationConfirmJour;               next setButtonEnabled();         SalesQuotationTable SalesQuotationTable1 = this.listPage().activeRecord(queryDataSourceStr(SalesQuotationListPage, SalesQuotationTable));         selec...

An error occurred during report data sets execution D365 For finance and operations

  Hi all, small tip. I faced this issue, when I extend the custom report in D365 for finance and operations. During development on onebox     Solution was simple, restart IIS services Restart Reporting Services. Happy Daxing.

CODE TO PDF IN AX 2012

static void Job1(Args _args) {         PurchPackingSlipController      ssrsController = new SrsReportRunController();         TradeDocumentReportContract     purchPackingSlipContract = new TradeDocumentReportContract();         SRSPrintDestinationSettings     printerSettings;         VendPackingSlipJour             VendPackingSlipJour;         Args                            args;         //select the latest record based on create date         while select VendPackingSlipJour             order by VendPackingSlipJour.createdDateTime DESC             where VendPackingSlipJour.PackingSlipId == 'LJ-01'         ...