Order & invoices
Overview
An order and invoices example, presented at MDENet eventThe Order and invoices application is an example of a simple, yet complex interprocess communication in the . This guide provides an overview of the development processes, focusing on the creation of workflows, forms, data fields, roles, transitions, and metadata using the and .
The application is runnable in the Demo environment or in your own instance of .
To learn how to install NAE CE locally or on a server, follow this tutorial.
Click here to launch Order process in Builder
Click here to launch Invoice process in Builder
Creation of the application
The main focus of this application example is interprocess communication, which is implemented using three simple functions.
The first one is executed on the pre-assign event in the Register invoice task, where all orders are collected into one enumeration field.
parent_order_id: f.parent_order_id;
def orders = findCases { it.processIdentifier.eq(workspace + "order")}.collectEntries {
[(it.stringId): "Order: " + it.stringId]
}
change parent_order_id options { orders }The second function is called on the post-finish event in the Register invoice task, where the field with id new_invoice_id is set.
invoice_id: f.invoice_id,
parent_order_id: f.parent_order_id;
def parent_order_case = findCase({ it._id.eq(parent_order_id.value) })
setData("t1", parent_order_case, [
"new_invoice_id": [
"value": invoice_id.value,
"type": "text"
]
])The third one is executed on the post-set event of the new_invoice_id . If the new_invoice_id value is not part of children_invoice_cases, the t2 task ID is assigned to the invoice_approvals task reference.
invoice_approvals: f.invoice_approvals,
children_invoice_cases: f.children_invoice_cases,
new_invoice_id: f.new_invoice_id;
if (new_invoice_id.value !in children_invoice_cases.value) {
change children_invoice_cases value { children_invoice_cases.value + new_invoice_id.value }
}
change invoice_approvals value {
findTasks{ (it.caseId.in(children_invoice_cases.value)).and(it.transitionId.eq("t2")) }?.collect{ it.stringId }
}