ProcessMaker Query Language (PMQL) is a query language similar to SQL, designed for searching and filtering data within ProcessMaker. It allows users to extract information related to requests, tasks, and collections.
PMQL has the following components:
Syntax: Syntax specifies the rules for building a PMQL search query. PMQL queries are structured with comparison and logical operators, and grouping mechanisms.
Data Types: Data types specify which type of ProcessMaker data to search. There are three data types in PMQL: Request, Task, and Collection.
Properties: Properties are the building blocks of a PMQL query; such as, process name, request or task status, participants, and dates associated with requests, tasks, or collection records.
How to Use PMQL in ProcessMaker
Requests: Perform advanced searches to find requests that match specific criteria. This can help in filtering and locating specific requests quickly.
Tasks: Use PMQL to sift through your tasks efficiently. This is especially useful for managing large volumes of tasks by filtering them based on various parameters.
Collection Records: Search through the records in a collection to find the information you need. This can significantly streamline the process of managing and accessing large data sets within collections.
PMQL Syntax
PMQL builds upon SQL syntax to use properties unique to ProcessMaker. PMQL supports the following SQL syntax:
Operators and Grouping Multiple Criteria
PMQL supports the following operators in and between each search criterion. The example for each comparative or logical operator assumes that the PMQL query searches against Request data for a Request variable (such as last_name
, experience
, and job_title
). See Request Information why data.
precedes each Request variable in each example.
LOWER
function to disregard request sensitivity in strings and request variablesIN
andNOT IN
operators for array values
LOWER
Function to Disregard Request Sensitivity in Strings and Request Variables
PMQL queries are request sensitive in regard to comparative and logical operators. If querying for a string or the value of a Request variable name, PMQL returns results only if the request exactly matches your query. Use the lower
function to disregard request-sensitivity evaluation by lower-casing strings and Request variable names. The lower
function is useful for when you are unsure of the request sensitivity of the comparing string or Request variable name.
Usage
lower(RequestVariable)
where RequestVariable
is the Request variable name
Example
lower(data.job_title) LIKE "prod%" OR lower(data.job_title) LIKE "proj%"
Comparative and Logical Operators
PMQL operators such as AND
, OR
, and LIKE
are not request-sensitive. PMQL operators are capitalized in this document for easier readability.
Spaces are allowed between operators. Example: data.last_name = "Canera"
Operator Description | Syntax | Example |
---|---|---|
Equal to |
|
|
Not equal to |
|
|
Less than |
|
|
Greater than |
|
|
Less than or equal to |
|
|
Greater than or equal to |
|
|
Search multiple required properties (logical operator) |
|
|
Search for any of multiple properties (logical operator) |
|
|
Group multiple logical operators | n/a |
|
Pattern matching |
| See |
LIKE
Operator for Wildcard Pattern Matching
Use the LIKE
operator, then include wildcards %
or _
within the quotation marks ("
) of your search parameter.
The
LIKE
operator is not request sensitive. However, this operator is capitalized in this document for easier readability.
The %
wildcard represents zero, one, or more characters. The _
wildcard represents exactly one character.
Wildcard Usage Examples
request LIKE "P%"
finds Requests associated with all Processes that begin withP
.status LIKE "c%"
finds Requests with both Completed and Canceled statuses.data.last_name LIKE "Ca%"
finds all values from Requests that begin withCa
in thelast_name
Request variable.data.last_name LIKE "Ca___"
finds all values from Requests that begin withCa
and those that match three following characters in thelast_name
Request variable.task LIKE "T%"
finds all Tasks that begin withT
.
See the following properties for more examples how to use the LIKE
operator:
requester
property for theRequest
data typecompleted
property for theTask
data type that includes an example how to find data in JSON arraysmodified
property for theTask
data typetask
property for theTask
data typecreated
property for theCollection
data type
Find Data in JSON Arrays
Use the LIKE
operator with the %
wildcard to find text in a specified JSON array within Request data. Consider the following JSON array in Request data that contains two JSON objects. Each JSON object contains the first name, last name, and email address.
"Personal": [
{
"FirstName": "Louis",
"LastName": "Canera",
"Email": "lcanera@mycompany.com"
},
{
"FirstName": "Jane",
"LastName": "Lowell",
"Email": "jlowell@yourcompany.com"
}
]
Use the following PMQL search query to find both persons in Request data based on the string company
. PMQL finds the string company
regardless of what string precedes or follows the sought pattern because the %
wildcard disregards all content in the JSON array preceding and following that pattern.
data.Personal LIKE "%company%"
See Example 2 for the completed
property for the Task
data type for another example.
IN
and NOT IN
Operators for Array Values
Use the IN
operator to search for data where the value of the specified property is one of multiple specified values.
Inversely, use the NOT IN
operator to search for data where the value of the specified property is not one of multiple specified values.
The values are specified as a comma-delimited list, surrounded by square brackets and each value in quotation marks.
See the following examples:
Find for completed or erroneous Tasks where the Request Date is not
2021-07-01
or2021-05-01
:(status IN ["Completed", "Error"]) AND data.date NOT IN ["2021-07-01", "2021-05-01"]
Find for completed or erroneous Requests where the Request Date is
2021-07-01
or2021-05-01
:(status IN ["Completed", "Error"]) AND data.date IN ["2021-07-01", "2021-05-01"]
Find for completed or in progress Requests where the participant is
admin
orMelissa
. The last modified is equal or major to2020-07-01 00:00:00
.participant IN ["admin", "Melissa"] AND status NOT IN ["Completed", "In Progress"] AND modified >= "2020-07-01 00:00:00"
CAST
Function to Convert Data Types
The CAST
function is a standard SQL syntax that PMQL supports for specific data types.
The
CAST
function is not request sensitive. However, this function is capitalized in this document for easier readability.
The CAST
function converts data from one data type to another. PMQL supports the CAST
function for the following data types:
Text: If the Request data stores the Request variable in the PMQL query as an integer (such as
2
), convert that value to text ("2").Number: If the Request data stores the Request variable in the PMQL query as text (such as "2"), convert that value to a number (
2
). For example, use theCAST
function in a PMQL query to perform a numerical comparison to theExperience
Request variable that stores a job candidate's experience in an industry to find job candidates with two (2) years of experience or greater, use the following PMQL query:CAST(data.Experience as number) >= 2
.
See the following properties for examples:
NOW
Keyword to Perform Temporal Comparisons from Now
The
NOW
keyword is not request sensitive. However, this keyword is capitalized in this document for easier readability.
The NOW
keyword represents the current datetime. Use the NOW
keyword in PMQL search queries to find Requests or Tasks in the following ways:
Dynamically compare the age of a Request or Task from the current datetime based on when the sought Request or Task was created or last modified. PMQL supports the following intervals of time:
second
minute
hour
day
Perform arithmetic operations on dates by using the following syntax:
date
operator
+
or-number
interval
where:
date
represents the dateoperator
represents the comparative operator+
or-
represents the addition or subtraction (respectively) from thedate
number
represents the number to add or subtract from thedate
interval
is the interval of time
See Example to Find Request Last Modified. See also the following property examples:
participant
property for theRequest
data typerequest
property for theRequest
data typecompleted
property for theTask
data typecreated
property for theTask
data typedue
property for theTask
data typeelement_id
property for theTask
data typemodified
property for theTask
data typerequest
property for theTask
data typestarted
property for theTask
data typestatus
property for theTask
data typemodified
property for theCollection
data type
Dynamically determine a chronological value of a Request variable from Request data as part of the PMQL search query. See Example Using Request Data.
Example to Find Request Last Modified
Use the following PMQL query search query to find Requests for ProcessName
that are not more than two (2) days old:
(modified < NOW -2 day) AND (request = "ProcessName")
Example Using Request Data
Find Requests from ProcessName
in which its Request participants are 25 years old or younger by only having their date of birth in a Request variable called DOB
, use the following PQML search parameter:
(data.DOB > NOW -9125 day) AND (request = "ProcessName")
Calculate the date of birth by subtracting 9125 days from the current datetime (365 * 25 = 9125).