Logo de Grixxo
Mastering Workflows in Oracle APEX: Part I

Mastering Workflows in Oracle APEX: Part I

Discover how to create, configure, and manage workflows in Oracle APEX to automate your business processes. At Grixxo, we show you how to leverage parameters, activities, and roles to transform efficiency in your projects.

7 minutes read

Table of Contents

  1. Introduction
  2. Create a Workflow in Your Workspace in Oracle APEX
    • 2.1. Workflow Versions
  3. Parameters
  4. Activities
    • 4.1. Activity Variables in APEX Workflows
    • 4.2. Options for Creating Activities in a Workflow
    • 4.2.1. Connection Rules Between Activities
    • 4.3. Roles in Workflows and Tasks in Oracle APEX
    • 4.4. Workflow Views in Oracle APEX
    • 4.4.1. Workflow Metadata Views
    • 4.4.2. Workflow Runtime Views
  5. Conclusion

1. Introduction

A workflow is the way tasks are organized and executed within a process.

It allows you to automate activities and visualize their progress in real time.

In this blog, we will explore its importance and functionality.

2. Create a Workflow in Your Workspace in Oracle APEX

This guide is a continuation of Automation in Oracle APEX v24 - Part I, so we will use the Blog - Task Automation application. Once inside the application, access Shared Components and select Automations.

Blog Image Blog Image

After clicking on Workflow, select Create to start the creation of a new workflow.

Blog Image

After creating our workflow, we must assign an identifier in the Name and Title fields. In our case, it is Blog - WorkFlow.

2.1 Workflow Versions

A workflow version can be in three states: In Development, Active, or Inactive.

  • In Development: It is editable and can only be executed in the developer’s session. Only one version can be in development.
  • Active: It is partially editable and only one active version is allowed. It cannot revert back to development.
  • Inactive: It cannot be used for new instances, but running instances continue until completion. Inactive versions can be deleted or duplicated.

When a workflow is created, it starts as In Development.

When it is moved to Active, the previous active version becomes Inactive.

Blog Image
SectionDescription
IdentificationWorkflow version: Defines the name of the specific workflow version. In this case, it is called Blog-WorkFlow. It is important for differentiating between different versions.
SettingsState: Defines the current state of the workflow version. - In Development: Editable, only executable in development. - Active: Executable in production, but cannot revert to development. - Inactive: Not active, does not initiate new workflows, but inactive versions can be deleted or duplicated.
Additional DataType: Defines how to obtain additional data for evaluating variables and conditions. - Table / View: Uses a table or view in the database. - SQL Query: Obtains data through a custom SQL query.
AdvanceDebug Level: Defines the workflow’s debug level. - Info: Default level, without specific details. - Warning: Logs warnings without interrupting the flow. - Error: Logs critical errors that halt the process. - Trace: Most detailed level, logs functions and procedures.
CommentsComments: Allows adding notes visible only in the App Builder. Useful for documenting the workflow.

3. Parameters

It is important to note that a workflow can have several parameters of different data types.

These can be defined within the workflow by right-clicking on the workflow.

Blog Image

When creating a parameter, the available attributes for the parameter will appear on the left.

Blog Image
ParameterDescription
IdentificationIndicates whether the parameter must always be provided when executing the workflow. If required, it must be present for the workflow to function correctly.
LabelThe user-friendly name that will be displayed to identify the parameter in the interface. It should be easy to understand for end users.
Additional InformationType: Field to add additional information about the parameter, such as its purpose or instructions. Supported Substitutions: Dynamic substitutions can be used within the parameter, such as application values, page items, or system variables.
ParameterData Type: Defines the expected data type. Options include:- VARCHAR2: Text string- TIMESTAMP: Timestamp- NUMBER: Number- BOOLEAN: True/false value- CLOB: Large text Direction: How the parameter is used in the workflow:- In: Passed into the workflow.- Out: Only comes out of the workflow.- In/Out: Passed into the workflow and also retrieved.Value: The value assigned to the parameter, which can be dynamic or static.
Default ValueThe default value that will be used if no other value is provided when executing the workflow. It prevents errors if the parameter is not explicitly set.
Additional InformationType: Text field to enter additional information about the parameter. Supported Substitutions: Dynamic application values, page items, and system variables can be used within the parameter, providing flexibility.

4. Activities

Workflows can have several activities, such as sending an email or a task definition. Below we present the available activities:

ActivityDescription
Workflow StartThe initial activity that starts the workflow. It is placed at the beginning of the process and cannot be preceded by any other activity.
Workflow EndMarks the end of a workflow or a branch of it. Once reached, the workflow terminates and no further activities are executed.
Workflow SwitchAllows the definition of conditional branches within the workflow. Based on certain conditions, the flow can be redirected to different activities.
Workflow WaitIntroduces a pause in the execution of the workflow. It can be configured to wait until a condition is met or a specified period of time has passed.
Human TaskCreates a task that is assigned to a user for manual action. It is linked to a preexisting task definition in the system.
Invoke APICalls an external API to perform an action.
Invoke WorkflowExecutes another workflow within the same application, allowing the creation of complex flows that depend on previously defined workflows.
Execute CodeAllows the execution of SQL or PL/SQL code directly within the workflow. It is used for specific operations or calculations during the execution of the workflow.
Send EmailSends an email as part of the workflow, useful for notifying users or systems about specific events.
Send Push NotificationSends a push notification to an associated application or mobile device. It is used to alert users in real time about actions or changes in the workflow.

4.1. Activity Variables in APEX Workflows

Each activity in a workflow can handle Activity Variables, which are values associated with the activity and can be used to:

  • Temporarily store information, such as the status of a task.
  • Pass data between activities, such as the user assigned to a task.
  • Determine conditions in a Workflow Switch, allowing the definition of which path to follow.

4.2. Options for Creating Activities in a Workflow

When designing a workflow, APEX allows you to add new activities at different positions within the diagram:

  1. Create Activity Below
    • Allows adding a new activity after the selected activity.
    • It is used to continue the normal flow of the process.
    • It cannot be used on Workflow End, as this activity ends the flow.
  2. Create Activity After
    • Similar to Below, but places the new activity as an independent step.
    • Useful when an activity may branch into two different paths.
  3. Create Connection
    • Allows connecting activities to define the execution order.
    • Cannot be connected to Workflow End, as this activity does not allow subsequent connections.

4.2.1 Connection Rules Between Activities

From → ToIs it possible?Notes
Workflow Start → Another activity✅ YesThe start activity always connects to another activity.
Any Activity → Workflow End✅ YesMarks the end of the flow.
Workflow End → Another activity❌ NoCannot be connected after the End.
Workflow Switch → Multiple activities✅ YesConditional routes can be defined.
Invoke Workflow → Another activity✅ YesSecondary workflows can be executed before continuing.
Send Email → Another activity✅ YesAfter a notification, the flow can continue.
Execute Code → Another activity✅ YesThe flow continues after executing PL/SQL code.

4.3. Roles in Workflows and Tasks in Oracle APEX

In Oracle APEX, roles in workflows determine what actions each user can perform within a workflow instance.

Main Roles:

  • Workflow Owners
    • They can start, end, and retry a workflow if an error occurs.
  • Workflow Administrators
    • They have advanced permissions to suspend, resume, and modify variables of a running workflow.

4.4. Workflow Views in Oracle APEX

Workflow views in Oracle APEX allow access to information about the definition, execution, and monitoring of workflows in the database.

They are divided into:

  • Metadata Views: Contain information about the structure and configuration of workflows.
  • Runtime Views: Provide data about the execution and current state of running workflows.

4.4.1 Workflow Metadata Views

ViewDescription
APEX_APPL_WORKFLOWSContains the definitions of workflows in the application, including the static workflow ID.
APEX_APPL_WORKFLOW_VERSIONSStores the versions of each workflow definition, allowing for change management.
APEX_APPL_WORKFLOW_ACTIVITIESSaves the definition of activities within a workflow (e.g., human tasks, email sending).
APEX_APPL_WORKFLOW_TRANSITIONSDefines the transitions between activities within the workflow (how the steps are connected).
APEX_APPL_WORKFLOW_BRANCHESContains the decision branches in switch-type activities, directing the flow according to conditions.
APEX_APPL_WORKFLOW_VARIABLESStores the variables defined at the workflow level (e.g., statuses, dates, responsible parties).
APEX_APPL_WORKFLOW_ACT_VARSSaves the variables associated with specific activities within the workflow.
APEX_APPL_WORKFLOW_PARAMSContains the definition of parameters used in workflows (e.g., dynamic values).
APEX_APPL_WORKFLOW_PARTICIPANTDefines the participants of the workflow (users or roles that can interact with it).
APEX_APPL_WORKFLOW_COMP_PARAMSStores the component parameters used in the Page Designer to configure workflows.

4.4.2 Workflow Runtime Views

These views store information about the execution and current state of the workflows in the application.

ViewDescription
APEX_WORKFLOWSContains the active workflow instances, with references to the flow definition.
APEX_WORKFLOW_ACTIVITIESSaves the instances of activities in execution, with references to their definitions.
APEX_WORKFLOW_PARAMETERSShows the parameter values in execution, including data type and format.
APEX_WORKFLOW_VARIABLESContains the values of variables used during the workflow execution.
APEX_WORKFLOW_ACTIVITY_VARSStores the variable values within specific activities of the workflow.
APEX_WORKFLOW_PARTICIPANTSShows the users or roles assigned to active tasks in running workflows.
APEX_WORKFLOW_AUDITRecords an audit history of workflows, including changes and transitions.

5. Conclusion

In summary, Workflows in Oracle APEX allow us to automate and structure business processes, facilitating the management of workflows with:

  • Human tasks, assigned to specific users.
  • Conditional transitions through Workflow Switch, enabling dynamic paths.
  • Code execution, integrating business logic within the workflow.

This improves operational efficiency and the traceability of processes within the organization.