APEX Workflows

James Sanna Dec 7, 2023 4:36:16 PM

Since the introduction of Approvals in APEX 22.1, Oracle has been continually working towards a fully integrated APEX solution for business process automation. And now included as part of 23.2, we see a significant stride with the latest addition: Workflows.

This innovative product is seamlessly woven into the APEX platform, offering a low-code, visually driven workflow designer that simplifies the creation, management, and automation of complex business processes. Workflows include a range of features such as:

  • A user-friendly Workflow Designer built with a familiar look and feel that resonates with the Application Page Designer.
  • Workflow Runtime Engine that evaluates and executes the workflow sequence.
  • A configurable Workflow Console page type that builds pages for users to view workflows they initiated or are a part of and for workflow administrators to perform administrative tasks.
  • Workflow APIs, using the APEX_WORKFLOW package

This blog will highlight some of the key features and properties of APEX Workflows.

APEX Workflow Components

Workflows are made using the Workflow Designer. This designer allows us to drag and drop built-in components into a diagram builder, creating a visual representation of the Workflow from start to finish. The familiar navigation tree and component attributes layout give you total control over every detail in each aspect of the Workflow.

APEX Workflows

There are several key building blocks used when designing the Workflow. These serve as the foundational elements of the complete Workflow process.

Parameters

Parameters are simply input sources for your Workflow. They are read-only values that do not change during the life cycle of your Workflow. When you create a Workflow process within your application, you can assign a value to each parameter using static values, items, and SQL queries returning single values, expressions, or function bodies. When defining a parameter, you can set the expected datatype, whether a value is required and must be set and a default value in place of null.

Variables

We can use Variables to store and control data throughout the Workflow. Similar to Parameters, the data within Variables can defined using an assortment of typical datatypes and can be populated in several ways. The main difference when using Variables is that every activity of the Workflow has the power to not just access but also modify the data within.

Activities

Activities are the most fundamental pieces of the Workflow. They represent individual steps to be actioned from start to finish. Each activity is responsible for performing a specific task, such as sending an email or notification, executing code, performing conditional checks, or triggering human task definitions. Workflow activities are organised into a sequential flow and can include branching and conditional logic to handle different scenarios. The types of activities include:

  • Workflow Start: A mandatory activity in any Workflow that signifies the starting point of the process.
  • Workflow End: Another mandatory activity that marks the end of the Workflow process. The Workflow End will have an end state attribute of either Completed or Terminated.
  • Execute Code: This activity will run a block of PL/SQL code or call function or procedure, either from a REST data source or within a local database.
  • Invoke API: Similar to Execute Code, The Invoke API activity will invoke a function or procedure from the parsing schema or REST source.
  • Human Task - Create: This activity can be used if you have created any Task Definitions within your application, which are actions that need some form of human intervention, such as approving or rejecting.
  • Switch – A switch is a decision-making activity that can traverse the Workflow in many directions based on true/false values, variable values, or SQL query results.
  • Wait – Pauses the Workflow until the date defined within the activity has passed. You can also pass the static ID of the Wait activity to the apex_workflow.continue_activity procedure to manually resume the Workflow.
  • Send Email – An activity that sends an email. Within this activity, you can define all the attributes, such as To/From addresses, subject, body, and attachments, and even use predefined email templates.
  • Send Push Notification – Sends a push notification to the subscribed devices of an application user.

Connections

Connections are the pathways between Workflow Activities. Every activity (except for Workflow Start and Workflow End) must have an incoming and outgoing connection. This allows the Workflow runtime engine to appropriately traverse through each step of the process from start to end.

Each connection can be of a few different types:

  • Normal type – Creates a simple link between two Activities
  • Error type – Uses a condition operator and value to capture error codes and handle them accordingly as part of the Workflow process.
  • Timeout – Where an Activity has a deadline date, if this date is breached then the Workflow will take this connection path.

Participants

Two types of participants can be defined in a Workflow:

  • Workflow Owner – A Workflow Owner is essential to be able to activate a Workflow from an in-development state. Any application user should have the ability to start and terminate a Workflow, but a Workflow Owner will also be able to re-run any that have encountered a fault during the workflow life cycle.
  • Workflow Administrator – This participant type can be assigned to someone who would have oversight of workflows within an application. They may not necessarily be involved in a Workflow but will have the power to suspend or terminate it, edit variable values, and view the core information such as parameters and workflow history.

These participant types can be defined using static values, SQL, or PL/SQL.

Workflow Versions and States

It is also worth mentioning that Workflows feature an aspect of versioning, and each version of one Workflow can exist in different states - In Development, Active, and Inactive.

When you start building your Workflow, you will create an initial version that will always start with the state of 'In Development'. During this state, you have complete control over the development of the Workflow and its components.

Once the in-development Workflow is finished and a Workflow owner participant has been set, you can then activate the Workflow. This moves the Workflow version into an Active state. Workflows in an Active state are considered a complete operating product, and APEX limits the amount of editing you can make to the Workflow. For example, when active, you cannot create new or delete existing Activities or Variables. You can make some adjustments to the settings of Activities, but it is recommended that you create a new version of the Workflow if any crucial changes are required.

To create a new version, right-click the Workflow within the Workflow Designer navigation tree and select 'Create Version'. You can then duplicate the existing Workflow version or create a new version from scratch, but remember you can only have one version as in development, and one as Active (but multiple Inactive).

APEX Workflows
APEX Workflows
When a new version is created, it will have a default state of In Development. If you then go on to activate this latest version, the previously Active version will become Inactive, and you will no longer be able to edit any of its properties.

Summary

It is worth checking out the Sample Workflow, Approvals, and Tasks application within the APEX Gallery to see Workflows in action.

Oracle continues to improve the capabilities of fully integrated process management and automation in APEX, and with the addition of Workflows, we see a boost in versatility, efficiency, and intuitive design of low-code development using APEX.

For more information, check out our APEX services, and if you liked this blog, check out our other APEX blogs here.

Remember to follow us on LinkedIn. We publish insight blogs on the latest technology developments every week.