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

Process of Sales order in Technical terms in D365Fo

 🔥 Sales Order Technical Flow in D365FO (Creation → Confirmation → Picking → Packing Slip → Invoice → Accounting) 1. Sales Order Creation Tables SalesTable → SO header SalesLine → SO lines CustTable → Customer master InventDim / InventDimCombination → Dimensions InventTable / EcoResProduct → Item master Framework Classes SalesTableType / SalesLineType Responsible for validation, defaulting, creation logic Key Methods SalesTable.initValue() SalesLine.initFromSalesTable() SalesTable.validateWrite() SalesLine.validateWrite() Events (Extensions) SalesTableType.createSalesTable() SalesLineType.createSalesLine() 2. Reservation (Optional) If reservation is done: Tables InventTrans (Reservation status) InventReservation Classes InventUpd_Reservation InventTransReservation Reservations impact picking and inventory availability. 3. Sales Order Confirmation Confirms order and freezes price/quantity. Posti...

Top 200 Q&A in D365FO Technical

  SECTION 1 — X++ BASICS (10 Q&A) 1. What is X++? A proprietary object-oriented language used in Dynamics 365 Finance & Operations for business logic, similar to C# but integrated with D365 runtime. 2. What is a TableBuffer? It is an in-memory object referencing a table. Example: CustTable custTable; 3. What is difference between select and select firstonly ? select → returns all matching rows firstonly → returns only the first matched row 4. What is ttsbegin & ttscommit ? Used to wrap database transactions; ensures atomicity. 5. Can we write SQL queries directly in X++? No. X++ uses a database-abstracted select statement. 6. What is a container? A collection datatype used to store mixed data types. 7. Difference between container and map? Map stores key-value pairs; container is indexed and immutable. 8. What is a temp table? A table that stores data temporarily in memory or database depending on property. 9. What is recursion in X++? A method c...

Process of Purchase order in Technical terms in D365Fo

  Purchase Order Technical Flow in D365FO (Step-by-Step) (From creation → approval workflow → posting → product receipt → invoice → accounting) 1. Purchase Order Creation Tables involved PurchTable → PO header PurchLine → PO lines VendTable → Vendor master InventDim / InventDimCombination → Item dimensions EcoResProduct / InventTable → Item master Classes / Framework PurchTableType / PurchLineType Framework that controls creation, validation, defaulting. Key methods PurchTable.initValue() PurchLine.initFromPurchTable() PurchTable.validateWrite() PurchLine.validateWrite() Events (Extension points) PurchTableType.createPurchTable() PurchLineType.createPurchLine() 2. Purchase Order Confirmation Document Status update PurchTable.DocumentState → Confirmation PurchParmBuffer tables used for versioning. Posting Class PurchFormLetter_Confirm Called internally via PurchFormLetter::construct(DocumentStatus::Co...