Overview

ProcessMaker uses a large number of functions and classes internally, which may be called inside triggers or plugins. The following is a small selection of the more useful functions, but many more can be found by looking in the source code.

Note: In PHP, variable names are case sensitive, but the names of functions, classes and class methods are not case sensitive, so the functions and classes listed below may appear with a different case in the ProcessMaker source code.

Source Code Locations

The most important PHP code files for ProcessMaker are located in the following locations:Gulliver:

<INSTALL-DIRECTORY>/gulliver/system/: This directory defines the principal classes for Gulliver, which is ProcessMaker's custom PHP development framework.

ProcessMaker classes:

<INSTALL-DIRECTORY>/workflow/engine/classes/: This directory defines the principal classes used by ProcessMaker.

<INSTALL-DIRECTORY>/workflow/engine/classes/model/: This directory defines the Propel classes and their Peer classes which correspond to tables in the database.

<INSTALL-DIRECTORY>/workflow/engine/classes/model/om/: This directory defines the abstract base classes from which the Propel classes in the model directory are derived (inherited).

RBAC classes:

<INSTALL-DIRECTORY>/rbac/engine/classes/: This directory defines the principal classes used by ProcessMaker's role based action control, which controls what functionality users can access based upon their roles.

<INSTALL-DIRECTORY>/rbac/engine/classes/model/: This directory defines the Propel classes and their Peer classes which correspond to tables in the database.

<INSTALL-DIRECTORY>/rbac/engine/classes/model/om/: This directory defines the abstract base classes from which the Propel classes in the model directory are derived (inherited).

ProcessMaker Interface Code:

<INSTALL-DIRECTORY>/workflow/engine/methods/: This directory contains the code executed by ProcessMaker screens and dialog boxes. These files are executed when a URL is entered in the web browser.

Files whose name terminates in _Ajax.php handle AJAX calls from other pages. In ProcessMaker 2.X, many of the pages were redesigned to use the Ext JS JavaScript framework in place of the old Maborak framework, however so it is possible to find both an Ext
JS and Maborak version of the same page. In version 2.0, most of these pages will be called inside of frames,
so turn on Time Logging or use the console in FireBug to see the URLs being used in the frames.

<INSTALL-DIRECTORY>/workflow/menus/: This directory holds the code to define the ProcessMaker menus.

ProcessMaker Pages:

<INSTALL-DIRECTORY>/workflow/templates/: This directory holds the HTML and JavaScript files (plus a few random PHP files) to display pages.

<INSTALL-DIRECTORY>/workflow/xmlform/: This directory holds the XML files, which are used to generate HTML forms. The format of the XML is the same as is used by Dynaforms. Note that in ProcessMaker 2.0 is switching to Ext JS which uses JavaScript instead of XML to generate HTML forms.

Calling Internal Functions and Classes

Some of the internal functions and classes are already included automatically when a trigger is fired, so the source files do not need to be imported in the trigger code. If using the internal functions and classes in a plugin, the source files will generally need to be imported.

Use the require_once() function to import a source file into a trigger or plugin code file, before calling the function or instantiating an object on that class:

require_once "path/to/file";
someFunctionOrClass(...);

The path to source files starts from the <INSTALL-DIRECTORY>/workflow/engine directory. For example, to instantiate a new webEntryProxy object, whose code is found at /opt/processmaker/workflow/engine/controllers/webEntryProxy.php, use:

require_once'controllers/webEntryProxy.php';$wep=new webEntryProxy();

The Gulliver framework also provides the following methods to import source code files:

G::LoadAllModelClasses(): Imports all the Propel model class definition files found at workflow/engine/classes/model/class-name.php, but does not import any of the class-namePeer.php files.

For more information about how to use these methods, see the source code at gulliver/system/class.g.php and the paths defined at workflow/engine/config/paths.php.

To reference a method (member function) of a class without instantiating an object for that class, use CLASS::function-name(). For example: Cases::loadCase() or G::SendTemporalMessage(). Note that class names in ProcessMaker generally start with uppercase and methods generally start with lowercase.

Exceptions from ProcessMaker Functions are generally caught and will not abort the trigger; however, ProcessMaker's internal functions may not have exception handling, so it is a good idea to wrap the code inside of try{...} catch{...} to gracefully handle exceptions.

Getting Information with ProcessMaker Classes

The information stored about ProcessMaker objects, such as processes, users, cases, etc. can be obtained by directly querying ProcessMaker's databases in MySQL (for example, using executeQuery() in a trigger, Propel::executeQuery() in a plugin or mysql_query() in an external script).

Database queries, however, are cumbersome, especially when querying several tables. It is more convenient to use ProcessMaker classes to obtain the same information.

The Load() method can be used by a variety of objects in ProcessMaker to return an associative array of information about the object. It works with many objects which have a unique ID in ProcessMaker. Most classes inherit this function from Propel, but a few reimplement it to add additional information.

arrayCLASS::Load()

The structure of the associative array returned by Load() depends upon each class. See the documentation below on the different classes.

Gulliver Functions

Functions and objects defined in Gulliver, which is the PHP development framework used internally by ProcessMaker, can be called from within triggers by prepending G:: to the function or class name. Most of Gulliver's functions are defined in the file gulliver/system/class.g.php.

G::LoadClass()

G::LoadClass() includes (i.e., imports into the code using the require_once() function) a class definition file which is stored in the location workflow/engine/classes/class.CLASS-NAME.php. The code file will only be included if it hasn't already been included.

variantG::LoadClass(string $strClass)

Parameters:

string$strClass: The CLASS-NAME of the code file found at workflow/engine/classes/class.CLASS-NAME.php. Note that the CLASS-NAME is case sensitive and almost always starts in lowercase.

Return Value:If able to find or open the file, then it returns false. If the code file was successfully included and it doesn't have a return statement, then it returns 1. Otherwise, it returns the value of the return statement.

Example:Import the workflow/engine/classes/class.groups.php code file. Then instantiate the Groups class found in that code file and call its Groups::getUsersOfGroup() method:

G::LoadSystem()

G::LoadSystem() includes (i.e., imports into the code using the require_once() function) a Gulliver class definition file which is stored in the location gulliver/system/class.CLASS-NAME.php. The code file will only be included if it hasn't already been included.

variantG::LoadSystem(string $strClass)

Parameters:

string$strClass: The CLASS-NAME of the code file found at gulliver/system/class.CLASS-NAME.php. Note that the CLASS-NAME is case sensitive and almost always starts in lowercase.

Return Value:If able to find or open the file, then it returns false. If the code file was successfully included and it doesn't have a return statement, then it returns 1. Otherwise, it returns the value of the return statement.

Example:Include the file /gulliver/system/class.xmlform.php:

G::LoadSystem('xmlform');//use a class from the imported file:$oField=new XmlForm_Field();

G::header()

G::header() is a wrapper for PHP's header() function, which sends raw HTTP headers. It can be used to redirect the browser to a different web page in ProcessMaker. Note that the G::header() function redirects to the current frame, but ProcessMaker version 2.0 uses several frames. To redirect to the top frame, see Browser Redirection.

voidG::header(string $string)

Parameters:

stringstring: The header string. To do redirection to a different web page, use the string "Location: <URL>". The URL can be a complete address such as "http://www.processmaker.com" or a relative address such as:

"Location: cases_List"

Opens the case list for the currently logged-in user.

"Location: casesListExtJs"

Opens the case list using the new ExtJS interface (available in ProcessMaker v.2.0) for the currently
logged-in user.

"Location: casesListExtJsRedirector"

Opens the case List using the new ExtJS interface in the parent frame of ProcessMaker v.2.0.

"Location: cases_New"

Opens screen to select the process on which to start a new case.

"Location: cases_Open?APP_UID=<CASE-UID>&DEL_INDEX=<INDEX>"

Opens the specified task in a case, as long as the current logged-in user has the proper privileges
to open that case. Remember that a user must either be the currently designated user to work on
the case or have Process Permissions for read-only access to the case. (For write access , make the user a Process Supervisor.) The APP_UID is the case unique ID
and the DEL_INDEX is the delegation index, which is an positive integer counting the tasks
in a process, starting from 1. Use the @@APPLICATION and @%INDEX system variables
to get the case UID and delegation index for the current case. For other cases, these values can
be looked up using the PMFCaseList() function, the caseList() web service or querying the wf_<WORKSPACE>.APP_DELEGATION.APP_UID and wf_<WORKSPACE>.APP_DELEGATION.DEL_INDEX fields in the database.

G::SendMessageText()

G::SendMessageText() displays a message to the user during the next screen. The message will flash twice and then stay on the screen until the user continues onto the next screen. It will be displayed at the top of the frame in a color which depends on the type of message.

voidG::SendMessageText(string $message, string $messageType)

Parameters:

string$message: The text to display to the user. The text can contain HTML markup, such as <font color="green">...</font> and <br> (line break).

string$messageType: The type of message, which can be "ERROR", "INFO" or "WARNING". Any other value will be displayed as a warning. The words "ERROR: ", "Info: " or "WARNING: " will be prepended to the message text.

Error messages will be white text on a red background. Their style is determined by temporalMessageERROR in style.css.

Warnings messages will be black text on a yellow background. Their style is determined by temporalMessageWARNING in style.css.

Information messages will be black text on a grey background. Their style is determined by temporalMessageINFO in style.css.

Return Value:None.

Note 1: Only one message can be displayed per frame, so don't try calling this function multiple times before a page is displayed.

Note 2: If the next screen gets completely overwritten, then the message may not be displayed to the user. This may happen if calling G::SendMessageText() in a Trigger after a step. If needing to be absolutely sure that the user will see a message, use PHP print statements followed by die() to stop ProcessMaker.

Example:

$g=new G();$g->SendMessageText("This case needs to be completed within the next 24 hours.","WARNING");

G::SendTemporalMessage()

G::SendTemporalMessage() displays a message to the user during the next screen. This method is similar to G::SendMessageText(), but offers more options.

string$msgID: The content of the message. Either a custom string to display to the user (if $sType is set to "STRING") or the message ID (if $sType is set to "LABEL" or "LABELS"). If a message ID, the message will be displayed in the current system language (if a translation is available). To see all the available message IDs, go to ADMIN > Settings > Language, select a language in the list and click on Export. Then open the PO translation file with a bare text editor. For more information, see Translating ProcessMaker and Customizing Interface Strings. If a custom string, then it can contain HTML markup, such as <font color="green">...</font> and <br> (line break). Note that all new lines ("\n") will automatically be replaced by HTML line breaks (<br>).

string$strType: The type of message, which is case insensitive and can be one of the following options:

"ERROR": Prepends the word "ERROR: " to the message and appears as white text on a red background. Its style is determined by temporalMessageERROR in style.css.

"TMP-ERROR": The same as "ERROR", but the message disappears from the screen after a certain amount of time.

"WARNING": Prepends the word "WARNING: " to the message and appears as black text on a yellow background. Its style is determined by temporalMessageWARNING in style.css.

"TMP-WARNING": The same as "WARNING", but the message disappears from the screen after a certain amount of time.

"INFO": Prepends the word "Info: " to the message and appears as black text on a grey background. Its style is determined by temporalMessageINFO in style.css.

"TMP-INFO": The same as "TMP-INFO", but the message disappears from the screen after a certain amount of time.

Any other value will prepend the word "Info: " to the message, but will display with the temporalMessageWARNING style. To customize how messages are handled, edit the files workflow/engine/templates/publish.php and workflow/engine/templates/publishBlank.php.

string$sType: Set to "LABEL" or "LABELS" if the first parameter is a message ID which will be displayed in the current system language. Set to "STRING" if the first parameter is a custom string. This parameter is case insensitive and defaults to "LABEL" if not included.

int$time: The amount of time in seconds that the message will be displayed to the user if $strType is set to "TMP-ERROR", "TMP-WARNING" or "TMP-INFO". If set to NULL or "" (empty string), then the message will be displayed for the default 5 seconds.

variant$width: The width of the message box as a percentage of the frame width. Can either be a integer such as 70 or a string such as "70%". If not included or set to NULL, then set to 65% of the frame by default.

array$customLabels: An associative array of custom labels to insert in the message. If the array key appears in the message as "{array-key}", then it will be replaced by the value for that key. See the example below.

Return Value:None.

Note 1: Only one message can be displayed per frame, so don't try calling this function multiple times before a page is displayed.

Note 2: If the next screen gets completely overwritten, then the message may not be displayed to the user. This may happen if calling G::SendMessageText() in a Trigger after a step. If needing to be absolutely sure that the user will see a message, use PHP print statements followed by die() to stop ProcessMaker.

Example:

Display an information message in a trigger fired before a DynaForm step:

G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_SYSTEM','info');

Display a custom error message for 3 seconds with the width set to "100%". Insert the variables in the custom message using the $customLabels parameter:

string$lang: Optional. Specify the language code for the translation, such as "en" (English), "es" (Spanish) or "zh-TW" (Chinese from Tiawan). If not specified, it will be the current ProcessMaker language (which can be found in the @@SYS_LANG system variable).

array$data: Optional. If the message contains text in the form "... {LABEL-ID} ...", then an associative array of keys and values can be used to replace the "{LABEL-ID}".

G::generateUniqueID()

G::generateUniqueID() returns a hexadecimal string which is 32 characters long to uniquely identify objects, such as cases, input documents, output documents, etc., in ProcessMaker. If manually creating new objects in ProcessMaker, use this function to generate the unique ID for that object.

stringG::generateUniqueID(void)

Parameters:None.

Return Value:A hexadecimal string 32 characters long.

Example:

$newId= G::generateUniqueID();

G::RenderPage()

G::RenderPage() sets the values of the global variables $G_TEMPLATE, $G_SKIN and $G_CONTENT, so that the content of a web page can be rendered and displayed to the user.

string$strTemplate: Optional. The name of the template file to use, which are defined in the workflow/engine/templates/ directory. Available ProcessMaker templates include:

"publish": Blank page with a header.

"publish-raw": Blank page which doesn't load any Javascript libraries and has no header.

"publishBlank": Blank page which does load the JavaScript libraries, but it doesn't have a header.

"publish-treeview": Page with a small sidebar and a larger content area (created with HTML DIVs).

"publish-twocolumns": Page with two content areas of the same size (created with HTML DIVs).

string$strSkin: Optional. The name of the skin which replaces the existing skin when rendering the page. If this parameter is not included, then the current skin will be used by default. If specifying this parameter, either use a custom skin or one of the following skins included in ProcessMaker:

"classic": Default skin in ProcessMaker 2.X.

"green": Default skin in ProcessMaker 1.X.

"blank": Skin which does not include a header at the top of the screen (which is useful for conserving space).

"raw": Skin which doesn't load any ProcessMaker's JavaScript libraries. This skin will prevent cases from running correctly since cases need the JavaScript libraries.

"extJs": Skin for displaying Ext JS content in ProcessMaker 2.X.

"green-submenu": Skin for displaying the content of a submenu in ProcessMaker 1.X.

object$objContent: This parameter is almost never used. It is recommended to use the Publisher::AddContent() method to set the content of the page.

G::getPathFromUID()

Available in version 2.5.1 and later.G::getPathFromUID() checks whether the ProcessMaker server is using the option to store files for cases in a series of 3 subdirectories generated from the case's ID and returns the correct path from a given case ID to access the files. By default, ProcessMaker stores the uploaded files for a case in the following path:{INSTALL-DIRECTORY}/shared/sites/{WORKSPACE}/files/{CASE-ID}/{CASE-DOC-ID}_{VERSION-NO}.{FILE-EXTENSION}
For example:/opt/processmaker/shared/sites/workflow/files/42316826755cbb5e0751cd5037067960/69609740455cbbde4ef5d70008261343_1.png
To get around the limitation in Linux's ext3 file system which limits directories to a maximum of 32K files, ProcessMaker 2.5.1 and later has an option to break the case ID into 3 subdirectories, such as:/opt/processmaker/shared/sites/workflow/files/423/168/267/55cbb5e0751cd5037067960/69609740455cbbde4ef5d70008261343_1.png
The G::getPathFromUID() method can be used to transform the case ID from "42316826755cbb5e0751cd5037067960" to "423/168/267/55cbb5e0751cd5037067960" if the system requires it.

//if the client number is found, then assign it to a case variable:if(preg_match('/Client No: ([A-Z0-9]{8})/',$contents,$match))@@ClientNo =$match[1];else@@ClientNo ='';

Publisher class

The Publisher class is used by the Gulliver framework to display web pages. It is defined at gulliver/system/class.publisher.php.

Publisher::AddContent()

Publisher::AddContent() adds content to a page before it is displayed (with the G::RenderPage() method). This function can be called multiple times to continue adding content to a page before displaying it. The content is inserted in the $parts array, which is a member variable of the Publisher class.

string$strType: The type of content to be added. This parameter determines how the content will be added by the Publisher::RenderContent0() method. Available content types include:

"view": Content is rendered with a template found in the gulliver/templates/ or /workflow/engine/plugins/<PLUGIN-NAME>/ directories.

"content": Same as "view".

"xmlform": Content is defined by XML code and its file is found in the workflow/engine/xmlform/ or /workflow/engine/plugins/<PLUGIN-NAME>/ directories. See the XML code for Dynaforms to understand the format.

"dynaform": A DynaForm defined for a process, whose file is found in the shared/sites/<WORKSPACE>/xmlForms/<PROCESS-UID>/ directory. It is processed the same as "xmlform".

"pagedtable": A table of data which is displayed with button controls to navigate pages of data. The table's fields are defined in an XML file found in the workflow/engine/xmlform/ or /workflow/engine/plugins/<PLUGIN-NAME>/ directories.

"propeltable": Like "pagedTable", but content data drawn from a database query.

"smarty": Content in the $parts->dataArray is rendered with an HTML Smarty template found in the gulliver/templates/ or /workflow/engine/plugins/<PLUGIN-NAME>/ directories.

"template":

"blank": Adds a blank space to the content.

"panel-init": Starts a panel.

"panel-tab": Adds a tab to a panel.

"panel-close": Ends a panel.

"externalContent": Adds external content with an external template. The content is loaded by G::LoadContent() and the template is loaded by G::LoadTemplateExternal().

"image": Content is an image file.

"appForm":

"menu":

"varform":

"table":

"graphLayout":

string$strLayout: A template (without the extension) which is found in workflow/engine/templates/ (or one of its subdirectories). The most common templates are:

"xmlform": Its file uses XML to define its fields which are laid out vertically.

"paged-table": Its file also uses XML to define its fields, but displays its data in columns and rows and has paging control buttons.

string$strName : The name of the file which defines the fields (but not the content or data). The file is found in the workflow/engine/xmlform/ or /workflow/engine/plugins/<PLUGIN-NAME>/ directory.

string$strContent: In most cases, set this to an empty string, but if $strType is "propelTable", then enter the criteria for the database query. The results of the query will be displayed in the table.

array$arrData: An associative array of data to include in the fields, where the keys are the field names and the values are the field values.

string$strTarget: The file which will process the content, which is located in the workflow/engine/methods/ or /workflow/engine/plugins/<PLUGIN-NAME>/ directory.

string$ajaxServer: The code file which will handle AJAX calls for the content, which is located in the workflow/engine/methods/ or /workflow/engine/plugins/<PLUGIN-NAME>/ directory.

string$mode: Set to "edit" if the content contains fields whose content can be edited by the user. Set to "" or "view" if the fields can't be edited.

boolean$bAbsolutePath: Set to true if the files have their complete path, rather than a relative path inside the default locations. If files a indicated with relative paths, then set to false.

headPublisher class

The headPublisher class is used by the Gulliver framework to display web pages. It is defined at gulliver/system/class.headPublisher.php. It is similar to the Publisher class, but it has more member functions and has been updated to deal with Ext JS. If working with Ext JS, it is recommended to use this class instead of the Publisher class.

headPublisher::AddContent()

The headPublisher::AddContent() method adds Ext JS content to a page, but it only adds an HTML template file to the private extJsContent[] array, which is a list of Ext JS files which will later be rendered when G::RenderPage() is called.

voidheadPublisher::AddContent(string $templateHtml)

Parameters:

string$templateHtml: The filename of the HTML template file to add to the forthcoming page that will be rendered. If the file has the extension ".html", then the extension does not need to be included. The HTML file should be located in the workflow/engine/templates/ or the workflow/engine/plugins/ directory. For example, the file workflow/engine/templates/groups/groupsList.html would be "groups/groupsList" and the file workflow/engine/plugins/deleteCases/deleteCasesApplication1.html would be "deleteCases/deleteCasesApplication1".

Return value:None.

headPublisher::renderExtJs()

The headPublisher::renderExtJs() method renders all the Ext JS HTML template files which have been added to the extJsContent[] array, so they can later be displayed in the web browser with G::RenderPage(). These files should have an extension of ".html". See headPublisher::AddContent().

stringheadPublisher::RenderExtJs()

Parameters:None.

Return value:The body of the HTML page, which has been created from the files in the the extJsContent[] array.

headPublisher::addExtJsScript()

The headPublisher::addExtJsScript() method adds a Ext JS code file, so it will be executed with the forthcoming page is rendered. The file must have an extension of ".js" and will be added to the extJsScript[] array, which is a list of Ext JS code files which will later be executed when the next page is rendered.

string$filename: The filename of the Ext JS code file to add to the forthcoming page that will be rendered. The file must have an extension of ".js", but do not include that extension in the filename. If the $isExternal parameter is set to false (which the default), then the Ext JS file should be found in the workflow/engine/templates/ or workflow/engine/plugins/ directories. For example, the file workflow/engine/templates/groups/groupsList.js would be "groups/groupsList" and the file workflow/engine/plugins/deleteCases/deleteCasesApplication1.js file would be "deleteCases/deleteCasesApplication1".

boolean$debug: Set to true if wishing to display debug messages from the

boolean$isExternal: Set to true if the file is not found in the standard locations of workflow/engine/templates/ or workflow/engine/plugins/. Make sure to include the full path to the Ext JS file in the $filename.

Return value:None.

headPublisher::Assign()

The headPublisher::Assign() method is used to pass a string variable from a PHP file to JavaScript. This variable will be added to the extVariable[] array. This method is often used to pass field labels and values to an Ext JS form.

voidheadPublisher::Assign(string $variable, string $value)

Parameters:

string$variable: The name of the variable to pass to JavaScript.

string$value: The value of the variable to pass to JavaScript. Note that this value should be a string.

Return value:None.

headPublisher::AssignVar()

The headPublisher::Assign() method is used to pass a string variable from a PHP file to JavaScript. This variable will be added to the vars[] array. This method is often used to pass field labels and values to a form. Unlike the headPublisher::Assign() method, this method can be used to pass any type of variable.

voidheadPublisher::AssignVar(string $name, string $value)

Parameters:

string$variable: The name of the variable to pass to JavaScript.

string$value: The value of the variable to pass to JavaScript. This value can be any variable type.

Return value:None.

headPublisher::clearScripts()

The headPublisher::clearScripts() method deletes all JavaScript files which have been added to the Ext JS content to a page, but it only adds an HTML template file to the private extJsContent[] array, which is a list of Ext JS files which will later be rendered when G::RenderPage() is called.

voidheadPublisher::AddContent(string $templateHtml)

Parameters:

string$templateHtml: The filename of the HTML template file to add to the forthcoming page that will be rendered. If the file has the extension ".html", then the extension does not need to be included. The HTML file should be found in the workflow/engine/templates/ directory or the workflow/engine/plugins/plugin-name/ directory. For example, the file workflow/engine/templates/groups/groupsList.html file would be "groups/groupsList" and the file workflow/engine/plugins/deleteCases/deleteCasesApplication1.html file would be "deleteCasesApplication1".

$G_SUB_MENU: This variable defines the submenu, which is the secondary menu below the top-level menu. ProcessMaker 2.X uses sidebars with options instead of submenus, although submenus can still be created with plugins in ProcessMaker 2.X. Common submenus in ProcessMaker 1.X include:

$G_MENU_SELECTED: This variable is an integer which defines which option in the top-level menu is currently selected. A value of 0 is the first option, 1 is the second option, 2 is the third option, etc. Set to -1 or "" (empty string) to not select any option.

Note that the number of options which are displayed depends upon the role of the logged in user and the
presence plugins, so don't rely on any option having a fixed number.

$G_SUB_MENU_SELECTED: This variable is an integer that identifies which option in the submenu is currently selected.

$G_ID_MENU_SELECTED: This variable defines which top-level menu option is currently selected, using the ID strings for the menus.New menu ID strings can be created, but by default the principal ProcessMaker menu includes the following menu options:

"PROCESSES": The PROCESSES menu option in version 1.X. The DESIGNER menu option in version 2.X.

"SETUP": The ADMIN menu option.

"CASES": The CASES menu option in version 1.X. The HOME menu option in version 2.X.

"DASHBOARD": The DASHBOARD menu option in versions 1.X and 2.0.34+.

$G_ID_SUB_MENU_SELECTED: This variable defines which submenu option is currently selected, using the ID strings for the menus.

$G_TMP_MENU: A temporary menu option which is not displayed to the user, but is often used before adding to a normal menu.

Example:To use the main ProcessMaker menu and the processes submenu and select the PROCESSES option in the main menu and the DYNAFORMS option in the submenu:

variant$strId: Sets the unique string to identify the menu. It is recommended to use a ID in upper case like "MYMENU". This parameter can either be a string with the ID or an array which also sets both the ID and a class for the ID. For example: array("MYMENU", "MyMenuClass")

string$strURL: Optional. A URL (which is generally a relative path) to the code file which should be executed when the menu option is clicked.

string$label: Optional. A text label for the menu.

string$icon: Optional. A URL (which is generally a relative path) to the icon image which is displayed next to the text label in the menu.

string$js: Optional. A bit of JavaScript to be executed when user clicks on the menu option, such as: 'showDbConnectionsList(Pm.options.uid); return false;'

PMPluginRegistry::registerMenu()

string$sNamespace: Name of the Gulliver application, which will be "processmaker" if building a plugin for ProcessMaker.

string$sMenuId: Name of the file which defines the menu. The file should be

string$sFilename: Name of the file which defines the menu, which should be located in the plugins/plugin-name/plugin-name/ directory.

PMPlugin class

The PMPlugin class, which is defined in the file workflow/engine/classes/class.plugin.php, provides methods to define plugins and register and manipulate elements of the plugin.

PMPlugin::registerMenu()

PMPlugin::registerMenu() registers the ID for a menu bar or a menu option and its code file, so it can be used by the plugin. This function passes its parameters onto PMPluginRegistry::registerMenu() to do the registration.

void PMPlugin::registerMenu(string $menuId, string $menuFilename)

Parameters:

string$menuId: Name to identify the menu.

string$menuFilename: Name of the PHP file which defines the menu, which should be located in the workflow/engine/plugins/plugin-name/ directory.

Cases class

The Cases class provides methods for manipulating ProcessMaker cases and is defined in the file workflow/engine/classes/class.case.php.

Cases::loadCase()

Cases::loadCase() returns an associative array of information about a specified case, as long as the current logged-in user has privileges to access the case. If the task is specified with the $iDelIndex parameter, it also returns information about the task.

arrayCases::loadCase(string $sAppUid, int $iDelIndex = 0)

Parameters:

string$sAppUid: The unique ID for a case. Set to @@APPLICATION for the current case or look it up in the wf_<WORKFLOW>.APPLICATION.APP_UID field for other cases.

int$iDelIndex: Optional. The delegation index, which is a positive integer which counts tasks in a process, starting from 1. If not specified or set to 0, then no task information will be returned. Set to @%INDEX for the current task in the current process or look it up in the wf_<WORKFLOW>.APP_DELEGATION.DEL_INDEX field for other cases.

Return Value:Returns an associative array of information about a case with the following structure:

array (

string["APP_UID"]: The unique ID for the case. Ex: "6654103664dcaee7a15e1e5076744766"

int["APP_NUMBER"]: The case number. Ex: 53

string["APP_PARENT"]: If the case is a subprocess, then the unique
ID for the parent case. If not subprocess, then "" (empty string).

string["APP_STATUS"]: The status of the case, which can be "TO_DO",
"DRAFT", "PAUSED", "CANCELLED", "COMPLETED" or "UNASSIGNED".

string["PRO_UID"]: The unique ID for the process.

string["APP_PROC_STATUS"]: Indicates the status of the process,
which is always "", since new cases can not be started if the process is set to "INACTIVE".

string["APP_PROC_CODE"]: A string to identify the case in the
case tracker. This value can be set with the setCaseTrackerCode() function.

string["APP_PARALLEL"]: Deprecated. Always set to "N" (even when there are parallel tasks).

string["APP_INIT_USER"]: The unique ID of the user who initiated
the case.

string["APP_CUR_USER"]: The unique ID of the user who is currently
assigned to work on the case. Note that this field may not updated due to this bug,
so use ["CURRENT_USER_UID"] instead.

string["APP_CREATE_DATE"]: The datetime when the case was created
in the format "YYYY-MM-DD HH:MM:SS". Ex: "2011-04-25 13:08:01"

string["APP_INIT_DATE"]: The datetime when the case was initiated
in the format "YYYY-MM-DD HH:MM:SS". This is always the same as the ["APP_CREATE_DATE"].

string["APP_FINISH_DATE"]: The datetime when the case finished
in the format "YYYY-MM-DD HH:MM:SS". If the case hasn't finished yet, then set to
"1902-01-01 00:00:00".

string["APP_UPDATE_DATE"]: The datetime when the case was last
updated in the format "YYYY-MM-DD HH:MM:SS".

array["APP_DATA"]: An associative array of the system variables
and case variables for the case when it was last stored, in the following format:

string["APP_PIN"]: An MD5 hash of the case PIN which can be used
when logging in with the Case Tracker.
For the unencrypted PIN, see ['APP_DATA']['PIN'].

string["APP_TITLE"]: The case title. If a custom case title has
not been set in the task properties, then this will be the case number with "#" prepended.
Ex: "#53"

string["APP_DESCRIPTION"]: The case description. If a custom
case description has not been set in the task properties, then this will be "" (an empty string).

string["STATUS"]: The case status, translated into the current
system language. Check the translations of the "ID_TO_DO", "ID_DRAFT", "ID_CANCELLED",
"ID_PAUSED", and "ID_COMPLETED" messages. In English, they are "To do", "Draft",
"Canceled", "Paused", and "Completed", respectively.

string["TITLE"]: The same as the ["APP_TITLE"].

string["CREATOR"]: The first and last name of the user who created
the case. Ex: "John Doe"

string["CREATE_DATE"]: The datetime when the case was created
in the format "YYYY-MM-DD HH:MM:SS".

string["UPDATE_DATE"]: The datetime when the case last updated
in the format "YYYY-MM-DD HH:MM:SS".

If the task was specified, then the following keys are also created:

string["TAS_UID"]: The unique ID for the task.

int["DEL_INDEX"]: The positive integer identifying the order
of the specified task in the process, which starts counting from 1.

int["DEL_PREVIOUS"]: The positive integer identifying the previous
task in the process, which starts counting from 1.

string["DEL_TYPE"]: The type of delegation for the task, which
is generally "NORMAL".

string["DEL_THREAD_STATUS"]: The status of the task's thread
which can be "OPEN" (if the case is TO DO or DRAFT) or "CLOSED" (if the case
is CANCELLED, PAUSED or COMPLETED).

int["DEL_THREAD"]: The positive number for the task's thread,
which starts counting from 1.

string["DEL_DELEGATE_DATE"]: The datetime when the case was routed
to the specified task in the process, in the format "YYYY-MM-DD HH:MM:SS".

string["DEL_INIT_DATE"]: The datetime when the specified task
was initiated, which is generally the same as the ["DEL_DELEGATE_DATE"].

string["DEL_TASK_DUE_DATE"]: The datetime when the task is scheduled
to be completed, according to the settings in the task properties and the calendar (which can
be determined by the user, task, process or workspace).

string["DEL_FINISH_DATE"]: The datetime when the task was completed
(or canceled). If not yet completed, then set to NULL.

string["CURRENT_USER_UID"]: The unique ID of the last user assigned
to work on the specified task. Note that if the specified task is not the current task in the
case, then this will not be the current user assigned to the case.

string["CURRENT_USER"]: The first and last name of the last user
assigned to work on the specified task. Note that if the specified task is not the current
task in the case, then this will not be the current user assigned to the case.

)

Example:Lookup the case title, current user and the case variable "ClientName" for the current case and display this information in a message in the next screen:

$c=new Cases();$aCase=$c->loadCase(@@APPLICATION,@%INDEX);$g=new G();$g->SendMessageText("Case {$aCase['APP_TITLE']} is assigned to {$aCase['CURRENT_USER']} "."and its ClientName is {$aCase['APP_DATA']['ClientName']}.","INFO");

Cases::loadCaseInCurrentDelegation()

Like Cases::loadCase(), Cases::loadCaseInCurrentDelegation() returns an associative array of information about a specified case, but the delegation index doesn't need to be specified, since it automatically selects the current delegation for the case.

arrayCases::loadCaseInCurrentDelegation(string $APP_UID)

Parameters:

string$APP_UID: The unique ID for a case. Set to @@APPLICATION for the current case or look it up in the wf_<WORKFLOW>.APPLICATION.APP_UID field for other cases.

Return Value:Returns an associative array with information about the specified case:array (

string["APP_UID"]: The case's unique ID.

int["APP_NUMBER"]: The case's number (which starts counting cases from
the number 1).

string["APP_UPDATE_DATE"]: The last time the case was updated in "YYYY-MM-DD HH:MM:SS" format.

int["DEL_PRIORITY"]: The case's priority which is a number between 1
and 5 and defaults to 3.

string["DEL_INDEX"]: The case's delegation index, which counts the number
of times a case has been routed to the next task, starting from the number 1.

string["TAS_UID"]: The unique ID of the current task for the case.

string["DEL_INIT_DATE"]: The datetime when the case's current task initiated
in "YYYY-MM-DD HH:MM:SS" format.

string["DEL_FINISH_DATE"]: The datetime when the case's current task
finished in "YYYY-MM-DD HH:MM:SS" format. If it hasn't finished yet, it will be set to NULL.

string["USR_UID"]: The unique ID of the user designated to work on the
case's current task.

Cases::startCase()

string$sTasUid: The unique ID for the task where the case will start. This task must be one of the starting tasks in the process. This ID can be found by going to ADMIN > Web Services Test and logging in as the user and then using the taskList() web service.

string$sUsrUid: The unique ID for the user will be assigned to the starting task for the case. This user must be one of the assigned users for that task.

boolean$isSubprocess: Optional parameter. Set to true if the case is run as a subprocess of a master process.

Return Value:An associative array with the following elements:

array (
string['APPLICATION']: Unique ID for the new case.
int['INDEX']: Positive integer to identify the current task of the new case.
string['PROCESS']: Unique ID for the process of the new case.
int['CASE_NUMBER']: Case number, which is a positive integer which counts cases.
)

int$iIndex: The delegation index for the case to cancel. This should be the index for the current task in the case.

string$user_logged: The unique ID for the user who cancels the case. This should be the user who is currently assigned to work on the case.

Example:Cancel the current case:

$c=new Cases();$c->cancelCase(@@APPLICATION,@%INDEX,@@USER_LOGGED);

Cases::removeCase()

Cases::removeCase() deletes a case and all its associated Input Documents, Output Documents and uploaded files.

voidCases::removeCase(string $sAppUid)

Parameters:

string$sAppUid: The unique ID of the case to remove.

Return Value:

Cases::removeCase() doesn't have a return value. If an exception occurs while executing Cases::removeCase(), the trigger will abort at that point and no subsequent code will be executed in the trigger and an exception message will be set in the @@__ERROR__ system variable (which can be checked in a subsequent trigger). For example, if $sAppUid is an invalid case unique ID, @@__ERROR__ will contain the message: "The row 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' in table Application doesn't exist!"

Examples:Delete the current case and redirect back to the cases list. Then, abort with the die() function, so the case will not continue to the next step (which will no longer exist, since the case has been removed from the database).

ProcessMaker slows down with large numbers of cases in the database. If it is not necessary to keep old cases in the system, this trigger code finds all cases which were completed or canceled over one year ago and deletes them.

string$sApplicationUID: The unique ID for the case. Note that this ID changes with each new task.

int$iDelegation: The current delegation index (which counts tasks starting from 1) for the case.

string$sUserUID: The unique ID for the currently assigned user to the task.

string$newUserUID: The unique ID for the user who will be assigned to the task.

string$sType: Optional. Set the type, which in almost all cases should be the default 'REASSIGN'.

Return Value:If the case was successfully reassigned, Cases::reassignCase() returns true. If unsuccessful, an exception is thrown and the trigger code stops at that point and an exception message is placed in the @@__ERROR__ system variable (which can be check in a subsequent trigger).

Example:When the current user goes on vacation, reassign all his/her cases to other users who are randomly chosen from the pool of assigned users for the current task of the cases.

$currentUser=@@USER_LOGGED;//lookup all current user's active cases:$query="SELECT * FROM APP_DELEGATION WHERE USR_UID='$currentUser' AND DEL_THREAD_STATUS='OPEN'";$cases= executeQuery($query);if(!is_array($cases)die("Error: Query failure:\n\n$query\n");

foreach($casesas$case){//lookup assigned users for the task:$taskId=$case['TAS_UID'];$assignedUsers=array();//empty array to hold the UIDs of the assigned users to the task$userQuery="SELECT USR_UID FROM TASK_USER WHERE TAS_UID='$taskId' AND TU_RELATION=1 AND USR_UID<>'$currentUser'";$users= executeQuery($userQuery);

foreach($usersas$user)$assignedUsers[]=$user['USR_UID'];

$groupQuery="SELECT GU.USR_UID FROM GROUP_USER GU, TASK_USER TU WHERE TU.TAS_UID='$taskId'
AND TU.TU_RELATION=2 AND TU.USR_UID=GU.GRP_UID AND TU.USR_UID<>'$currentUser'";$users= executeQuery($groupQuery);

foreach($usersas$user)$assignedUsers[]=$user['USR_UID'];

$assignedUsers=array_unique($assignedUsers);//eliminate any duplicates in array$noUser=rand(1,count($assignedUsers));//get random number to select the user$designatedUser=$assignedUsers[$noUser];$c=new Cases();$c->reassignCase($case['APP_UID'],$case['DEL_INDEX'],$case['USR_UID'],$designatedUser);}die();//stop the current case because it has been reassigned to another user

Cases::setCatchUser()

Assigns a user to a case whose current task has a self-service assignment rule and it is not yet assigned to a user. Note that only a user who in the list of assigned users for the task can be assigned to the case.

string$sProUid: Optional. The unique ID of the process. If not included, then the current process will be used.

string$sAppUid: Optional. The unique ID of the case. If not included, then the current case will be used.

int$iDelIndex: Optional. The delegation index of the case, which is a positive integer counting the tasks in a case starting from 1. If not included, then the current task in the current case will be used.

int$iPosition: Optional. The step in the case, which is a positive integer counting the steps in a case, starting from 1. If not included, then the current step in the current case will be used.

Return Value:An associative array with information about the next step in the specified case, with the following structure:

array(
['TYPE'],
['UID'],
['POSITION'],
['PAGE']
)

Where:

string['TYPE']: The type of step, which can be 'DYNAFORM', 'OUTPUT_DOCUMENT', 'INPUT_DOCUMENT', 'EXTERNAL' or 'MESSAGE'.

string['UID']: The unique ID for the next step.

int['POSITION']: The position of the next step, which is a positive integer which counts the steps in a task, starting from 1.

string['PAGE']: A relative URL which can be used to redirect to the next step with the G::header() function.

If the specified step is the last step in the task, then this array will be returned pointing to the end of the task which assigns the case to the next user:

string$sProUid: Optional. The unique ID of the process. If not included, then the current process will be used.

string$sAppUid: Optional. The unique ID of the case. If not included, then the current case will be used.

int$iDelIndex: Optional. The delegation index of the case, which is a positive integer counting the tasks in a case starting from 1. If not included, then the current task in the specified case will be used.

int$iPosition: Optional. The step in the case, which is a positive integer counting the steps in a case, starting from 1. If not included, then the current step in the specified case will be used.

Return Value:An associative array with information about the previous step in the specified case, with the following structure:

associative array
(
['TYPE'],
['UID'],
['POSITION'],
['PAGE']
)

Where:

string['TYPE']: The type of step, which can be 'DYNAFORM', 'OUTPUT_DOCUMENT', 'INPUT_DOCUMENT', 'EXTERNAL' or 'MESSAGE'.

string['UID']: The unique ID for the previous step.

int['POSITION']: The position of the previous step, which is a positive integer which counts the steps in a task, starting from 1.

string['PAGE']: A relative URL which can be used to redirect to the previous step with the G::header() function.

If there is no previous step available, then a value of false will be returned.

Example:To redirect the web browser to the previous step in the current case:

Cases::updateCase()

Cases::updateCase() overwrites a case's variables, by serializing the variables and storing them in the wf_<WORKSPACE>.APPLICATION.APP_DATA field in the database.

arrayCases::updateCase(string $sAppUid, array $Fields = array())

Parameters:

string$sAppUid: The unique ID of the case whose variables will be updated.

array$Fields: Optional. An associative array which should contain a key named "APP_DATA" which points to an associative array of the variables. In this associative array, the keys are the names of the variables and the array values are the values of the variables. If the $Fields parameter is not included, then the case's variables will be erased. The easiest way to get a correct array structure for the $Fields parameter is to use Cases::loadCase() and then use array_merge() to update its ['APP_DATA'] member array. See the example below.

Return Value:Returns the $Fields parameter, whose contents has been modified by

Note: If updating the current case in a trigger, keep in mind that many steps automatically update a case's variables, so your changes will be overwritten. For this reason, it is recommended to use PMFSendVariables() instead of Cases::updateCase() to update the current case in a trigger.

Example:Set the variable "clientAccount" to "2012_FINANCE_Y34" and the variable "clientName" to "Jane Doe" for a case with the unique ID "8078850464f60dda169adc4033523707":

Use the query: SELECT CON_VALUE, CON_ID FROM CONTENT WHERE CON_CATEGORY='TAS_TITLE'

Return Value:An associative array with the following elements:array(

string["PRO_UID"]: The unique ID of the process for this task.

string["TAS_UID"]: The unique ID of the task.

string["TAS_TYPE"]: The type of task, which is either "NORMAL" or "SUBPROCESS" for a task which is a subprocesses.

float["TAS_DURATION"]: The expected duration of the task.

string["TAS_DELAY_TYPE"]: by default set to "" (empty string).

float["TAS_TEMPORIZER"]: by default set to 0.

string["TAS_TYPE_DAY"]: by default set to "" (empty string).

string["TAS_TIMEUNIT"]: by default set to "DAYS".

string["TAS_ALERT"]: by default set to "FALSE".

string["TAS_PRIORITY_VARIABLE"]: Variable which determines the priority
of the task, which by default is "@@SYS_CASE_PRIORITY". This variable should contain a value
between 1 and 5.

string["TAS_ASSIGN_TYPE"]: The type of assignment, which is "BALANCED" or "EVALUATE" (if using Value Based Assignment and not using the default @@SYS_NEXT_USER_TO_BE_ASSIGNED variable).

string["TAS_ASSIGN_VARIABLE"]: The variable which determines which is
the next designated user to work on the task if using Value Based Assignment. By default, set to "@@SYS_NEXT_USER_TO_BE_ASSIGNED".

string["TAS_MI_INSTANCE_VARIABLE"]: The variable which determines the
total number instances if using the discriminator. By default set to "@@SYS_VAR_TOTAL_INSTANCE". This
field is no longer used.

string["TAS_MI_COMPLETE_VARIABLE"]: The variable which determines the
total number instances which need to be completed by the discriminator. By default set to "@@SYS_VAR_TOTAL_INSTANCES_COMPLETE".
This field is no longer used.

string["TAS_ASSIGN_LOCATION"]: By default set to "FALSE"

string["TAS_ASSIGN_LOCATION_ADHOC"]: by default set to "FALSE"

string["TAS_TRANSFER_FLY"]: By default set to "FALSE"

string["TAS_LAST_ASSIGNED"]: The unique ID of the last user designated
to work on this task. If a user has never been designated then set to "0".

string["TAS_USER"]: By default set to "0".

string["TAS_CAN_UPLOAD"]: By default set to "FALSE".

string["TAS_VIEW_UPLOAD"]: By default set to "FALSE".

string["TAS_VIEW_ADDITIONAL_DOCUMENTATION"]: By default set to "FALSE".

string["TAS_CAN_CANCEL"]: By default set to "FALSE"

string["TAS_OWNER_APP"]: By default set to "FALSE"

string["STG_UID"]: By default set to "" (empty string).

string["TAS_CAN_PAUSE"]: Set to "TRUE" if the task can be paused; otherwise,
set to "FALSE".

string["TAS_CAN_SEND_MESSAGE"]: Set to "TRUE" if the task can send out
email notifications; otherwise, set to "FALSE".

string["TAS_CAN_DELETE_DOCS"]: by default set to "FALSE".

string["TAS_SELF_SERVICE"]: Set to "TRUE" if the task has a Self Service
designation rule. Otherwise, set to "FALSE".

string["TAS_START"]: Set to "TRUE" if the task is an initial task which
can start a case. Otherwise, set to "FALSE".

string["TAS_TO_LAST_USER"]: By default set to "FALSE".

string["TAS_SEND_LAST_EMAIL"]: Set to "TRUE" if the After routing notify
the next assigned user(s) option is checked in the configuration of the task.

string["TAS_DERIVATION"]: The type of derivation which is always "NORMAL".

int["TAS_POSX"]: The X position of the task in pixels in the process
map.

int["TAS_POSY"]: The Y position of the task in pixels in the process
map.

int["TAS_WIDTH"]: The width in pixels of the task graphic in the process
map. By default set to 165.

int["TAS_HEIGHT"]: The height in pixels of the task graphic in the process
map. By default set to 40.

string["TAS_COLOR"]: The color of the task in the process map. By default
set to "" (empty string).

string["TAS_EVN_UID"]: By default set to "" (empty string).

string["TAS_BOUNDARY"]: By default set to "" (empty string).

string["TAS_DEF_DESCRIPTION"]: By default set to "" (empty string).

string["TAS_DEF_MESSAGE"]: By default set to "" (empty string).

string["TAS_DEF_PROC_CODE"]: By default set to "" (empty string).

string["TAS_DEF_SUBJECT_MESSAGE"]: By default set to "" (empty string).

string["TAS_DEF_TITLE"]: By default set to "" (empty string).

string["TAS_DESCRIPTION"]: The description of the task.

string["TAS_TITLE"]: The title of the task.

)

Example:Get the title and description of the current task to display in DynaForm fields named "taskTitle" and "taskDescription":

Derivation class

Class to manipulate the routing (derivation) of cases to the next task(s) in the process and is defined in workflow/engine/classes/class.derivation.php.

Derivation::getAllUsersFromAnyTask()

Derivation::getAllUsersFromAnyTask() returns an array of unique IDs for the users assigned to a task.

arrayDerivation::getAllUsersFromAnyTask(string $sTasUid);

Parameters:

string$sTasUid: The unique ID for a task.

Return Value:An array of unique IDs for users assigned to the task, ordered by the UIDs. Note that the function will also return users who are assigned to the task through groups. Duplicate UIDs will be eliminated.

Example:If the case variable @@cantHandleCase is true, send an email to all the other users assigned to the current task, asking them to take the case because the currently designated user can't handle it.

Derivation::getDerivatedCases()

Derivation::getDerivatedCases() returns information about any subprocess cases which were created after a specified delegation index in a specified case. This function is used to find out which subprocess cases were created by a master case.

int$sDelIndexParent: The delegation index for the parent (master) case.

Return Value:An array of associative arrays which contains information about the subprocess case(s) which were created after a specified delegation index in a master case. If no subprocess cases were created, then returns an empty array.array (

[0]: array (

string["processId"]: The unique ID of the subprocess.

string["processTitle"]: The title of the subprocess

string["caseId"]: The unique ID of the subprocess case.

int["caseNumber"]: The case number of the subprocess case.

string["taskId"]: The unique ID of the initial task in the subprocess
case.

string["taskTitle"]: The title of the initial task in the subprocess
case.

string["userId"]: The unique ID of the user designated to the
initial task in the subprocess case.

string["userName"]: The username of the user designated to the
initial task in the subprocess case.

string["userFullname"]: The first and last name (separated by
a space) of the user designated to the initial task in the subprocess case.

)

[1]

...

)

Example:Send an email to the current user of a master case about a subprocess case which was created after the second task in the process.

Derivation::setTasLastAssigned()

Derivation::setTasLastAssigned() sets the user who was last designated to work on a task, so that tasks which use cyclical assignment will select the next user in the list returned by Derivation::getAllUsersFromAnyTask(). This function writes the user's unique ID to the wf_<wORKSPACE>.TASK.TAS_LAST_ASSIGNED field in the database.

voidDerivation::setTasLastAssigned(string $tasUid, string $usrUid)

Parameters:

string$tasUid: The unique ID for the task.

int$usrUid: The unique ID for the user who will be set as the last user for the task.

Return Value:None.

Example:The next task in the process uses cyclical assignment, but in some special cases the user working on the current task should also be designated to work on the next task as well, so normal cyclical assignment shouldn't occur. To force the current user to be assigned to the next task, first use Derivation::getAllUsersFromAnyTask() to get a list of the users and find where the current user is in the list. Then, set the user before the current user in the list as the last one to work on the task with Derivation::setTasLastAssigned(). That way PMFDerivateCase() will assign the current user as the next user when it routes the case.

if(@@continueWorkingOnCase){$nextTask='1095301964f75dc9c223865073314383';//set to the UID of the next task in the process//G::LoadClass('derivation'); //not necessary in triggers$d=new Derivation();$aUsers=$d->getAllUsersFromAnyTask($nextTask);$prevUserIndex=array_search($aUsers,@@USER_LOGGED)-1;//get the user before the current userif($prevUserIndex<0)//if current user is at the start of the array, then set to user at end of array$prevUserIndex=count($aUsers)-1;//subtract one because arrays start counting from zero$d->setTasLastAssigned($nextTask,$aUsers[$prevUserIndex]);
PMFDerivateCase(@@APPLICATION,@%INDEX);}

AppDelegation class

Class to manipulate case delegations. A case delegation happens when a case is routed to another task in the process and a user is delegated to work on that task. A case delegation also happens when a case is unpaused and when a case is reassigned (i.e., delegated to a different user). Delegations are distinguished by their delegation index, which counts delegations in a case starting from the number 1 and increments with each new delegation. The case delegation information is stored in the wf_<WORKSPACE>.APP_DELEGATION table and the AppDelegation class is defined in workflow/engine/classes/model/AppDelegation.php.

AppDelegation::Load()

AppDelegation::Load() returns an array of information about a specified case delegation.

arrayAppDelegation::Load(string $AppUid, string $sDelIndex)

Parameters:

string$AppUid: The unique ID for a case.

string$DelIndex: The delegation index. This index counts the case delegations (i.e., routing the case to a task and delegation of that task to a user) starting from the number 1.

Note:$DelIndex can be set to current delegations which have a status of "OPEN" and past delegations which have a status of "CLOSED", but it can't be set to future delegations which haven't yet occurred and don't yet have a record in the wf_<WORKSPACE>.APP_DELEGATION table.

Return Value:An associative array with the following information about the case delegation:array (

string["APP_UID"]: The unique ID of the case.

int["DEL_INDEX"]: The index of this delegation in the case. Delegation
indexes start counting from the number 1.

int["DEL_PREVIOUS"]: The index of the previous delegation in the case.
If there was no previous delegation, because this delegation started the case, then set to 0.

string["PRO_UID"]: The unique ID of the process.

string["TAS_UID"]: The unique ID of the task executed by this delegation.

string["USR_UID"]: The unique ID of the User delegated (designated) to
work on the task.

string["DEL_TYPE"]: The type of delegation, which is almost always "NORMAL"

string["DEL_THREAD"]: The thread of this delegation. Threads start counting
from the number 1 and are used to keep track of the different branches in a process.

string["DEL_THREAD_STATUS"]: The status of this delegation, which can
be either "OPEN" or "CLOSED".

string["DEL_PRIORITY"]: The priority of this delegation which can be "1" (very low), "2" (low), "3" (normal), "4" (high) or "5" (very high).

string["DEL_DELEGATE_DATE"]: The datetime in "YYYY-MM-DD HH:MM:SS" format when this delegation was designated (delegated) to a user.

string["DEL_INIT_DATE"]: The datetime in "YYYY-MM-DD HH:MM:SS" format when this delegation was initiated. If the case was reassigned to another user, then this field
will be set to NULL.

string["DEL_TASK_DUE_DATE"]: The datetime in "YYYY-MM-DD HH:MM:SS" format when this delegation is scheduled to be completed, based upon the expected Task Duration and calculated with the calendar of the user->task->process->workspace (depending on which is defined). Note that the due date
is calculated when the case routes to another task in the process or when the case is unpaused or reassigned to another user.

string["DEL_FINISH_DATE"]: The datetime in "YYYY-MM-DD HH:MM:SS" format when the delegation was finished, meaning that its status was changed to "CLOSED".
If it hasn't yet finished, then set to NULL. Note that a delegation can be finished without
completing the steps in the task, which can happen when a case is canceled, paused or forcibly routed
with PMFDerivateCase().

float["DEL_DURATION"]: Deprecated field. Always set to 0.

float["DEL_QUEUE_DURATION"]: Deprecated field in PM 2.0. Always set to
0.

float["DEL_DELAY_DURATION"]: Deprecated field in PM 2.0. Always set to
0.

int["DEL_STARTED"]: Deprecated field in PM 2.0. Always set to 0.

int["DEL_FINISHED"]: Deprecated field in PM 2.0. Always set to 0.

int["DEL_DELAYED"]: Deprecated field in PM 2.0. Always set to 0.

string["DEL_DATA"]: Deprecated field in PM 2.0. Always set to "" (empty string).

float["APP_OVERDUE_PERCENTAGE"]: Deprecated field in PM 2.0. Always set
to 0.

)

Example:If the due date for the current case delegation has already passed (i.e., is less than the current datetime), then display a warning message.

require_once"classes/model/AppDelegation.php";$oAD=new AppDelegation();$aAD=$oAD->Load(@@APPLICATION,@%INDEX);$dueDate=strtotime($aAD["DEL_TASK_DUE_DATE"]);if($dueDate<time())//if overdueç$g=new G();$g->SendMessageText("This case was due on {$aAD['DEL_TASK_DUE_DATE']}.""WARNING");

AppDocument class

The AppDocument class is defined in workflow/engine/classes/model/AppDocument.php and is used to manipulate uploaded files, Input Document files and generated Output Documents in ProcessMaker. Note that an AppDocument is a document associated with a particular case and is not the definition of an Input Document or an Output Document. The record for an AppDocument is stored in the wf_<WORKSPACE>.APP_DOCUMENT table and its file(s) are located in the <INSTALL-DIRECTORY>/shared/sites/<WORKSPACE>/files/<CASE-UID>/ directory.

Query the wf_<WORKSPACE>.APP_DOCUMENT.APP_DOC_UID field in the database.

Use the query: SELECT CON_VALUE, CON_ID FROM CONTENT WHERE CON_CATEGORY='APP_DOC_FILENAME'

int$iVersion: Optional. The AppDocument's version number, which starts counting from the number 1. If not included or set to null, then the information about the latest version of the document is returned. The version number can be found by querying the APP_DOCUMENT.DOC_VERSION field in the database.

Return Value:An associative array with the following elements:array(

string["APP_DOC_UID"]: The unique ID of the AppDocument.

int["DOC_VERSION"]: The version number of the AppDocument. Counting starts
from 1. Even if versioning isn't enabled, AppDocuments will have a version number.

string["APP_UID"]: The unique ID of the case where the AppDocument was
uploaded (if an attached file or Input Document file) or generated (if an Output Document). Attached
files uploaded through the HOME > Documents interface will not have an APP_UID.

int["DEL_INDEX"]: The delegation index of the task where the AppDocument
was uploaded or generated. Attached files uploaded through the HOME > Documents interface will not have an APP_UID.

string["DOC_UID"]: The unique ID of the Input Document or Output Document
definition. If an attached file, then will be set to "-1".

string["USR_UID"]: The unique ID of the user who uploaded or generated
the AppDocument.

string["APP_DOC_TYPE"]: The type of AppDocument which can be: "ATTACHED",
"INPUT" or "OUTPUT". Note the files uploaded through the HOME > Documents interface are "INPUT".

string["APP_DOC_CREATE_DATE"]: Datetime when the AppDocument was created in the "YYYY-MM-DD HH:MM:SS" format. For attached files and Input Document files,
this is the time when the file was uploaded. For Output Documents, this is the time when its files
were generated.

int["APP_DOC_INDEX"]: The index number for the AppDocument. Index numbers
are used by Input Documents to determine the order which they are displayed in the list of files. Counting
starts from the number 1.

string["FOLDER_UID"]: The unique ID of the folder where the file is found
under HOME > Documents. If not located in a folder, then set to "" (empty string).
Note that this folder has not relation to the location of the AppDocument's file which stored in the
file sytem.

string["APP_DOC_PLUGIN"]: By default set to "" (empty string).

string["APP_DOC_TAGS"]: Tags for the AppDocument, separated
by commas. If there are no tags, then set to NULL. Tags are used to identify and find AppDocuments.
Files uploaded through HOME > Documents will have a tag of "EXTERNAL".

string["APP_DOC_STATUS"]: The status of the AppDocument, which
can be: "ACTIVE", "INACTIVE" or "DELETED"

string["APP_DOC_STATUS_DATE"]: The datetime when the status changed.
If never changed, then set to NULL.

string["APP_DOC_TITLE"]: The title of the AppDocument. This
feature is no longer used and is always set to "" (empty string).

string["APP_DOC_COMMENT"]: The comment which was entered when an Input
Document file is uploaded.

string["APP_DOC_FILENAME"]: The filename of the AppDocument.
The extension is included in the filename for Input Document files and attached files, but not included
for Output Documents.

)

Note:If unable to find the file's UID in the APP_DOCUMENT table, AppDocument::Load() will throw an exception and set @@__ERROR__ to "Error loading Document /0. This row doesn't exist!"

Example:
Get the files for the Input Document with the UID "86062325056a02c39e62e51079553933" and place information about them in a grid variable which will be displayed in a subsequent DynaForm:

//set to the UID of an Input Document:$inputDocId="86062325056a02c39e62e51079553933";$caseId=@@APPLICATION;//UID of the current case@=InputDocGrid =array();

$query="SELECT APP_DOC_UID FROM APP_DOCUMENT WHERE APP_UID='$caseId' AND
DOC_UID='$inputDocId' AND APP_DOC_STATUS='ACTIVE'";$results= executeQuery($query);

AppDocument::remove()

AppDocument::remove() deletes an AppDocument, which is can be an attached file, Input Document file or generated Output Document file. This method does not remove the file from the server's file system, nor does it remove the file's record from the APP_DOCUMENT table in the database. It simply changes the APP_DOCUMENT.APP_DOC_STATUS from 'ACTIVE' to 'DELETED'.

AppDocument::Remove(string $sAppDocUid, int $iVersion = 1)

Parameters:

string$sAppDocUid: The unique ID of an AppDocument, which can be found in the following ways:

Query the wf_<WORKSPACE>.APP_DOCUMENT.APP_DOC_UID field in the database.

Use the query: SELECT CON_VALUE, CON_ID FROM CONTENT WHERE CON_CATEGORY='APP_DOC_FILENAME'

int$iVersion: Optional. The AppDocument's version number, which starts counting from the number 1. To get the latest version, check the ['DOC_VERSION'] returned by AppDocument::load('UID', null).

Return Value:None. Wrap the code in try{...} catch{...} to find out whether there was a failure executing the method.

Parameters:

The following code deletes all the files in the current case. For each file, it calls AppDocument::remove(). It also constructs the path to the file depending upon whether it is an Output Document file or an Input Document file (or attached file) and then calls unlink() to delete the file from the file system.

$caseId=@@APPLICATION;$query="SELECT * FROM APP_DOCUMENT WHERE APP_UID='$caseId' AND APP_DOC_STATUS<>'DELETED'";$aDocs= executeQuery($query);

InputDocument class

The InputDocument class is defined in workflow/engine/classes/model/InputDocument.php and is used to manipulate the definition of Input Documents, which are stored in the wf_<WORKSPACE>.INPUT_DOCUMENT table in the database.

InputDocument::Load()

InputDocument::Load() returns information about the definition of an Input Document.

arrayInputDocument::Load(string uid)

Parameters:

stringuid: The unique ID of an Input Document, which can be found in the following ways:

Open a process, go to Input Documents and click on the UID button in the list.

string["INP_DOC_ORIGINAL"]: If the INP_DOC_FORM_NEEDED is "REAL" or "VREAL"), the format of that original document, which can be: "ORIGINAL", "COPY" or "COPYLEGAL".

string["INP_DOC_PUBLISHED"]: Always set to "PRIVATE".

int["INP_DOC_VERSIONING"]: Set to 1 if versioning is enabled.
Otherwise, set to 0.

string["INP_DOC_DESTINATION_PATH"]: The destination path, which is a
directory or a path of directories where the Input Document files will be found under under HOME > Documents.

string["INP_DOC_TAGS"]: Tags to easily identify and find the Input Document
files. If multiple tags, separated them by commas.

string["INP_DOC_TITLE"]: The title of the Input Document.

string["INP_DOC_DESCRIPTION"]: The description of the Input Document.

)

Example:

$i=new InputDocument();$i->Load('1565194984f490ade7727b6065039420');

OutputDocument class

The OutputDocument class is defined in workflow/engine/classes/model/OutputDocument.php and is used to manipulate the definition of Output Documents, which are stored in the wf_<WORKSPACE>.OUTPUT_DOCUMENT table in the database.

Use the query: SELECT CON_VALUE, CON_ID FROM CONTENT WHERE CON_CATEGORY='TRI_TITLE'

Return Value:An associative array with the following elements:array (

string["TRI_UID"]: The unique ID of the trigger.

string["PRO_UID"]: The unique ID of the process.

string["TRI_TYPE"]: The trigger type, which is always "SCRIPT".

string["TRI_WEBBOT"]: The trigger code, which comes from a mediumtext
field in MySQL

string["TRI_PARAM"]: Trigger parameters. If the trigger was created with
a wizard, this field contains a serialized array with the trigger code created by the wizard and an
MD5 hash of that code. If the contents of TRI_WEBBOT do not hash to the same value, then ProcessMaker
knows that the trigger code has been edited and will display the code in text editing window, rather
than displaying it in the wizard.

string["USR_USERNAME"]: The user's username, which must be unique and
is case insensitive.

string["USR_PASSWORD"]: An MD5 hash of the user's password,

string["USR_FIRSTNAME"]: The user's first name. Up to 50 characters long.

string["USR_LASTNAME"]: The user's last name. Up to 50 characters long.

string["USR_EMAIL"]: The user's email address. Up to 100 characters long.

string["USR_DUE_DATE"]: The date when th in the "YYYY-MM-DD HH:MM:SS" format.

string["USR_CREATE_DATE"]: The datetime when the user's profile was first
created in the "YYYY-MM-DD HH:MM:SS" format.

string["USR_UPDATE_DATE"]: The datetime when the user's profile was last
updated in the "YYYY-MM-DD HH:MM:SS" format.

string["USR_STATUS"]: The user's status, which can be: "ACTIVE",
"INACTIVE" or "ON_VACATION". Only users with "ACTIVE" status can login to
the system.

string["USR_COUNTRY"]: A 2 character code to identify the user's country.
To find the full name of the country, do a search in the wf_<WORKSPACE>.ISO_COUNTRY table.

string["USR_CITY"]: This element (which is misnamed), is a 1-3 character
code for the region or state. To find the full name of the region or state, do a search in the wf_<WORKSPACE>.ISO_SUBDIVISION table.

string["USR_LOCATION"]: A 3 character code for the location (which is
generally a city or county). To find the full name of the location, do a search in the wf_<WORKSPACE>.ISO_LOCATION table.

string["USR_ADDRESS"]: The address. Up to 255 characters long.

string["USR_PHONE"]: The telephone number. Up to 24 characters long.

string["USR_FAX"]: The fax number. Up to 24 characters long.

string["USR_CELLULAR"]: The cellular telephone number. Up to 24 characters
long.

string["USR_ZIP_CODE"]: The postal code or zip code. Up to 16 characters
long.

string["DEP_UID"]: The unique ID for the user's department.

string["USR_POSITION"]: The user's position. Up to 100 characters long.

string["USR_RESUME"]: Up to 100 characters long.

string["USR_BIRTHDAY"]: The date of the birthday in the "YYYY-MM-DD" format.

string["USR_ROLE"]: The name of the role.

string["USR_REPORTS_TO"]: The unique ID for the user who the user reports
to, i.e., the user's manager or supervisor.

string["USR_REPLACED_BY"]: The unique ID for the user who replaces this
user when he/she goes on vacation or leave.

string["USR_UX"]: The User Experience interface for the user, which can be: "NORMAL", "SIMPLIFIED" or "SWITCHABLE".
The simplified interface is designed for smartphones and mobile devices which use have less screen
space and use finger touches and no right clicks.

)

Note: In most situations, it is recommended to use userInfo() to obtain user information, but Users::Load() can be used when extra information is needed.

Example:Send an email from the current user's supervisor to the current user. Get the position of the current user, so that it will be inserted into the body of an email which contains the variable @#userPosition:

//G::LoadClass("users"); //necessary if not in a trigger$u=new Users();$aUserInfo=$u->Load(@@USER_LOGGED);$supervisorEmail="boss@example.com";if(!empty($aUserInfo["USR_REPORTS_TO"])){$aSupervisorInfo= userInfo($aUserInfo["USR_REPORTS_TO"]);$supervisorEmail=$aSupervisorInfo['mail'];}
PMFSendMessage(@@APPLICATION,$supervisorEmail,$aUserInfo['USR_EMAIL'],'','',"Send me a case report",'reportOnCase.html',array('userPosition'=>$aUserInfo['POSITION']));

Users::userExists()

intUsers::userExists(string $UsrUid)

Users::getAllInformation()

arrayUsers::getAllInformation(string $UsrUid)

Users::getAll()

arrayUsers::getAll(int $start=null, int $limit=null, $search=null)

Groups class

The Groups class is defined in workflow/engine/classes/class.groups.php and is used to manipulate groups in ProcessMaker.

Groups::getUsersOfGroup()

Get the assigned users of a group.

arrayGroups::getUsersOfGroup(string $sGroupUID)

Parameters:

string$sGroupUID: The unique ID of a group, which can be found in the following ways:

Use the query: SELECT CON_VALUE, CON_ID FROM CONTENT WHERE CON_CATEGORY='GRP_TITLE'

Return Value:An array of associative arrays with information about each user in the group:array(

int [0]: array(

string["USR_UID"]: The user's unique ID.

string["USR_USERNAME"]: The user's username, which must be unique
and is case insensitive.

string["USR_PASSWORD"]: An MD5 hash of the user's password,

string["USR_FIRSTNAME"]: The user's first name. Up to 50 characters
long.

string["USR_LASTNAME"]: The user's last name. Up to 50 characters
long.

string["USR_EMAIL"]: The user's email address. Up to 100 characters
long.

string["USR_DUE_DATE"]: The date when th in the "YYYY-MM-DD HH:MM:SS" format.

string["USR_CREATE_DATE"]: The datetime when the user's profile
was first created in the "YYYY-MM-DD HH:MM:SS" format.

string["USR_UPDATE_DATE"]: The datetime when the user's profile
was last updated in the "YYYY-MM-DD HH:MM:SS" format.

string["USR_STATUS"]: The user's status, which can be: "ACTIVE",
"INACTIVE" or "ON_VACATION". Only users with "ACTIVE" status can
login to the system.

string["USR_COUNTRY"]: A 2 character code to identify the user's
country. To find the full name of the country, do a search in the wf_<WORKSPACE>.ISO_COUNTRY table.

string["USR_CITY"]: This element (which is misnamed), is a 1-3
character code for the region or state. To find the full name of the region or state, do a
search in the wf_<WORKSPACE>.ISO_SUBDIVISION table.

string["USR_LOCATION"]: A 3 character code for the location (which
is generally a city or county). To find the full name of the location, do a search in the wf_<WORKSPACE>.ISO_LOCATION table.

string["USR_ADDRESS"]: The address. Up to 255 characters long.

string["USR_PHONE"]: The telephone number. Up to 24 characters
long.

string["USR_FAX"]: The fax number. Up to 24 characters long.

string["USR_CELLULAR"]: The cellular telephone number. Up to
24 characters long.

string["USR_ZIP_CODE"]: The postal code or zip code. Up to 16
characters long.

string["DEP_UID"]: The unique ID for the user's department.

string["USR_POSITION"]: The user's position. Up to 100 characters
long.

string["USR_RESUME"]: Up to 100 characters long.

string["USR_BIRTHDAY"]: The date of the birthday in the "YYYY-MM-DD" format.

string["USR_ROLE"]: The name of the role.

string["USR_REPORTS_TO"]: The unique ID for the user who the
user reports to, i.e., the user's manager or supervisor.

string["USR_REPLACED_BY"]: The unique ID for the user who replaces
this user when he/she goes on vacation or leave.

string["USR_UX"]: The User Experience interface for the user, which can be: "NORMAL",
"SIMPLIFIED" or "SWITCHABLE". The simplified interface is designed for smartphones
and mobile devices which use have less screen space and use finger touches and no right clicks.

Groups::getGroupsForUser()

Groups::getGroupsForUser() returns a list of groups to which a specified user is assigned. It is like Groups::getActiveGroupsForAnUser(), but it returns an associative array of information about the group. Note that it only returns groups which have an active status.

arrayGroups::getActiveGroupsForAnUser(string $usrUid)

Parameters:

string$usrUid: The unique ID of a user.

Return Value:An associative array of associative arrays with information about the groups. The outer associative array has keys which group unique IDs.array (

string["GROUP-UID-1"]: The unique ID of the first group.

array (

string["GRP_UID"]: The group's unique ID.

string["GRP_STATUS"]: The group's status, which can only
be "ACTIVE", since searching for "ACTIVE" groups.

string["CON_VALUE"]: The group's title, which is looked
up in the wf_<WORKSPACE>.CONTENT.CON_VALUE table.

)

string["GROUP-UID-2"]: The unique ID of the second group.

...

)

Example:Display a list of groups for the current user in a DynaForm grid named "groupsGrid" which contains the fields "uid" and "groupName".

Groups::verifyUserToGroup()

Groups::verifyUsertoGroup() verifies whether a specified user is a member of a specified group.

intGroups::verifyUsertoGroup(string $GrpUid, string $UsrUid)

Parameters:

string$GrpUid: The unique ID of a group.

string$UsrUID: The unique ID of a user.

Return Value:Returns 1 if the user is a member of the group. Otherwise returns 0.

Note: This method does not check whether the group and user have active status, so there is no guarantee that the user or group can be used after the user is added to it.

Example:If the current user is a member of a group named "Employees", then set @@canHandleTask to "yes", which is a variable used in a subsequent condition in an evaluation routing rule. Looked up the unique ID for the "Employees" group in the wf_<WORKSPACE>.CONTENT table.

string["GRP_UX"]: The User Experience interface for the group, which can be: "NORMAL", "SIMPLIFIED" or "SWITCHABLE".
The simplified interface is designed for smartphones and mobile devices which use have less screen
space and use finger touches and no right clicks.

Department class

The Department class is defined in workflow/engine/classes/model/Department.php and is used to manipulate departments in ProcessMaker, which are stored in the wf_<WORKSPACE>.DEPARTMENT table in the database.

Department::Load()

Department::Load() returns information about a department.

arrayDepartment::Load(string uid)

Parameters:

stringuid: The unique ID of a department, which can be found in the following ways:

Use the query: SELECT CON_VALUE, CON_ID FROM CONTENT WHERE CON_CATEGORY='DEPO_TITLE'

Return Value:An associative array with the following elements:array (

string["DEP_UID"]: The unique ID of the department.

string["DEP_PARENT"]: The unique ID of the parent department. If no parent,
then set to "" (an empty string).

string["DEP_MANAGER"]: The unique ID of the user who is the manager/supervisor
of the department.

int["DEP_LOCATION"]: Always set to 0.

string["DEP_STATUS"]: The department's status, which can be "ACTIVE" or "INACTIVE". If "INACTIVE", then no additional users can be assigned to the department
and "reports to" designation rules don't work with the department.

Department::updateDepartmentManager()

Step class

The Step class is defined in workflow/engine/classes/model/Steps.php and is used to manipulate steps in ProcessMaker, which are stored in the wf_<WORKSPACE>.STEP table in the database.

Step::Load()

Step::Load() returns information about a step.

arrayStep::Load(string uid)

Parameters:

stringuid: The unique ID of a step, which can be found in the wf_<WORKSPACE>.STEP.STEP_UID field in the database.

Return Value:An associative array with the following elements:array(

string["STEP_UID"]: The unique ID for the step.

string["PRO_UID"]: The unique ID for the task where the step occurs.

string["TAS_UID"]: The unique ID for the task's process.

string["STEP_TYPE_OBJ"]: The type of object executed by the task which
can be: "DYNAFORM", "INPUT_DOCUMENT", "OUTPUT_DOCUMENT" or "EXTERNAL".

string["STEP_UID_OBJ"]: The unique ID of the object which is executed
by the step.

string["STEP_CONDITION"]: The text of the condition for the step to execute.
If "" (an empty string), then the step will always execute.

int["STEP_POSITION"]: The step's position, which indicates the order
that steps execute in a task. Counting starts from 1.

string["STEP_MODE"]: The mode of the fields in a DynaForm, which can
be: "EDIT" (all fields are editable), "VIEW" (all fields are read-only) or "" (determined by the Mode property of each individual field).

Dynaform class

The Dynaform class is defined in workflow/engine/classes/model/Dynaform.php and is used to manipulate Dynaforms in ProcessMaker, which are stored in the wf_<WORKSPACE>.DYNAFORM table in the database.

Dynaform::Load()

Dynaform::Load() returns information about a task.

arrayDynaform::Load(string uid)

Parameters:

stringuid: The unique ID of a DynaForm, which can be found in the following ways:

Query the wf_<WORKSPACE>.DYNAFORM.DYN_UID field in the database.

Use the query: SELECT CON_VALUE, CON_ID FROM CONTENT WHERE CON_CATEGORY='DYN_TITLE'

Return Value:An associative array with the following elements:array(

string["DYN_UID"]: The unique ID of the DynaForm.

string["PRO_UID"]: The unique ID of the process which contains the DynaForm.

string["DYN_TYPE"]: The DynaForm type, which is "grid" or "xmlform" (for a master form).

string["DYN_FILENAME"]: The filename (without the extension) where the
XML code and HTML code is stored in the file system. The filename consists of the process UID and DynaForm
UID separted by a "/" (forward slash). For example: "7766592404f358fb90dcdc9043579725/6876293754f358fcb61d704036851199"

Calendar class

The Calendar class is defined in workflow/engine/classes/class.calendar.php and is used to manipulate calendars in ProcessMaker, which are stored in the CALENDAR_DEFINITION,CALENDAR_BUSINESS_HOURS, CALENDAR_HOLIDAYS and CALENDAR_ASSIGNMENTS tables in the database.

Calendar::getCalendarInfo()

Calendar::getCalendarInfo() returns information about a task.

arrayCalendar::getCalendarInfo(string CalendarUid)

Parameters:

stringCalendarUid: The unique ID of a Calendar, which can be found with the Calendar::loadByCalendarName() method or by querying the wf_<WORKSPACE>.CALENDAR_DEFINITION.CALENDAR_UID field in the database.

Return Value:An associative array with the following elements:array (

string["CALENDAR_UID"]: Unique ID for the calendar in the CALENDAR_DEFINITION table.

string["CALENDAR_NAME"]: The name of the calendar.

string["CALENDAR_CREATE_DATE"]: Datetime when the calendar was created
in "YYYY-MM-DD HH:MM:SS" format.

string["CALENDAR_UPDATE_DATE"]: Datetime when the calendar was last updated
in "YYYY-MM-DD HH:MM:SS" format.

string["CALENDAR_DESCRIPTION"]: Description of the calendar.

string["CALENDAR_STATUS"]: The calendar's status, which can be "ACTIVE" or "INACTIVE".

array["CALENDAR_WORK_DAYS_A"]: The calendar's workdays in an array. For
example: array("0", "5", "2")

array["BUSINESS_DAY"]: An array of the business hours for the calendar
(which are drawn from the CALENDAR_BUSINESS table). Note that the counting
of the array starts from 1, and not from 0 like a normal array.

(

array[1]: An array with data from each business hour record.

(

string["CALENDAR_UID"]: The unique ID of the calendar
in the CALENDAR_DEFINITION table.

string["CALENDAR_BUSINESS_DAY"]: The day of the week,
where where 0 = Sunday, 1 = Monday, 2 = Tuesday, etc. 7 represents all other business
dayswhich haven't been otherwise specified.

string["CALENDAR_BUSINESS_START"]: The start of the business
hours in "HH:MM" format.

string["CALENDAR_BUSINESS_END"]: The end of the business
hours in "HH:MM" format.

string["UPPER(CALENDAR_BUSINESS_HOURS.CALENDAR_BUSINESS_DAY)"]:
The day of the week, where where 0 = Sunday, 1 = Monday, 2 = Tuesday, etc. 7 represents
all other business days which haven't been otherwise specified.

string["UPPER(CALENDAR_BUSINESS_HOURS.CALENDAR_BUSINESS_START)"]:
The start of the business hours in "HH:MM" format.

)

...

)

array["HOLIDAY"]: An array of holidays for the calendar, which are drawn
from the CALENDAR_HOLIDAYS table. Note that the counting of the array starts
from 1, and not from 0 like a normal array.

(

array[1]: An array of information about each holiday record.

(

string["CALENDAR_UID"]: The unique ID of the calendar
in the CALENDAR_DEFINITION table.

string["CALENDAR_HOLIDAY_NAME"]: The name of the holiday.

string["CALENDAR_HOLIDAY_START"]: The date when the holiday
starts in "YYYY-MM-DD" format. Note that years are ignored when determining
holidays.

string["CALENDAR_HOLIDAY_END"]: The date when the holiday
ends in "YYYY-MM-DD" format. Note that years are ignored when determining
holidays.

)

...

)

)

Example:Display the holidays in a grid named @@holidayGrid which has fields named "CALENDAR_HOLIDAY_NAME", "CALENDAR_HOLIDAY_START" and "CALENDAR_HOLIDAY_END":

AppFolder class

The AppFolder class is defined in workflow/engine/classes/model/AppFolder.php and is used to manipulate folders found under HOME > Documents in ProcessMaker, which are stored in the wf_<WORKSPACE>.APP_FOLDER table in the database.

AppFolder::Load()

AppFolder::Load() returns an array of information about an AppFolder object.

arrayAppFolder::Load(string $uid)

Parameters:

stringuid: The unique ID of the AppFolder.

Return Value:An associative array with the following elements:array (

string["FOLDER_UID"]: The unique ID of the folder.

string["FOLDER_PARENT_UID"]: The unique ID of the parent folder. If the
folder is in the root folder, then set to "/".

string["FOLDER_NAME"]: The name of the folder.

string["FOLDER_CREATE_DATE"]: The datetime the folder was created in
"YYYY-MM-DD HH:MM:SS" format.

string["FOLDER_UPDATE_DATE"]: The datetime the folder was last updated
in "YYYY-MM-DD HH:MM:SS" format.

AppMessage class

The AppMessage class is defined in workflow/engine/classes/model/AppMessage.php and is used to manipulate email notifications in ProcessMaker, which are stored in the wf_<WORKSPACE>.APP_MESSAGE table in the database.

Getting AppMessage Information

Because AppMessage doesn't have a primary key, the Load() method will not work. Instead use the toArray() method to get an array of information about the AppMessage object.

array (

string["APP_MSG_UID"]: The unique ID of the email message (i.e., the
AppMessage object).

string["MSG_UID"]: This field is no longer used and is always "" (an empty string).

string["APP_UID"]: The unique ID of the case which sent the message.

string["DEL_INDEX"]: The delegation index of the task where the message
was generated.

string["APP_MSG_TYPE"]: Type of message, which can be "TEST" (when configuring Email settings),
"DERIVATION" (when automatically notifying the next assigned users)
or "TRIGGER" (when sending messages with a Trigger function or an Event).

string["APP_MSG_SUBJECT"]: The subject line of the email.

string["APP_MSG_FROM"]: The email address of the message sender.

string["APP_MSG_TO"]: The list of email addresses of the recipients.

string["APP_MSG_BODY"]: The text of the body of the email message.

string["APP_MSG_DATE"]: Datetime when the message was created in "YYYY-MM-DD HH:MM:SS" format.

string["APP_MSG_CC"]: List of email addresses of the carbon copy recipients.

AppHistory class

The AppHistory class, which is defined in workflow/engine/classes/model/AppNotes.php, is used to store the changes in field values in each DynaForm. This information is used by the Change Log and is perminently stored the wf_<WORKSPACE>.APP_HISTORY table in the database. This information can be used for auditing purposes. Note that the class doesn't automatically store changes made by Process Supervisors.

AppHistory::getDynaformHistory()

AppHistory::getDynaformHistory() returns a Criteria object to query the APP_HISTORY table for a specified case and task (and optionally a specified DynaForm). This Criteria object can be used with the AppHistoryPeer::doSelect() or AppHistoryPeer::doSelectOne() methods to get AppHistory objects.

Getting AppHistory Information

To get an associative array of information from an AppHistory object, first use the getDynaformHistory() method to return a Criteria object. Then, pass that Criteria object to the doSelect() or doSelectOne() method to populate objects. Finally, call the toArray() method to export an associative array of information about the AppHistory object.

The toArray() method will return an associative array with the following structure:array (

string["APP_UID"]: The unique ID of the case.

int["DEL_INDEX"]: The delegation index of the task which contains the
DynaForm step.

string["PRO_UID"]: The unique ID of the process step.

string["TAS_UID"]: The unique ID of the task which contains the DynaForm
step.

string["DYN_UID"]: The unique ID of the DynaForm.

string["USR_UID"]: The unique ID of the user who submitted the DynaForm.

string["APP_STATUS"]: The status of the case when the data was submitted,
which can be "TO_DO" or "DRAFT".

string["HISTORY_DATE"]: The datetime when the data was submitted in the
"YYYY-MM-DD HH:MM:SS" format.

string["HISTORY_DATA"]: A serialized associative array of the case data when it was submitted to the database. For more information on the
serialized format, see Variable Storage.

)

AdditionalTables class

The AdditionalTables class is defined in workflow/engine/classes/model/AdditionalTables.php and is used to manipulate PM Tables and Report Tables in ProcessMaker, whose definitions are stored in the wf_<WORKSPACE>.ADDITIONAL_TABLES table in the database. The PmTable class inherits from the the AdditionalTables class.

AdditionalTables::Load()

arrayAdditionalTables::Load(string $uid)

Return Value:

array (

string["ADD_TAB_UID"]: The unique ID of the table.

string["ADD_TAB_NAME"]: The name of the table.

string["ADD_TAB_CLASS_NAME"]: The Propel class name of the table.

string["ADD_TAB_DESCRIPTION"]: The description of the table.

int["ADD_TAB_SDW_LOG_INSERT"]: Set to 1 if insertions are logged. Otherwise,
set to 0. No longer used in version 2.0.

int["ADD_TAB_SDW_LOG_UPDATE"]: Set to 1 if updates are logged. Otherwise,
set to 0. No longer used in version 2.0.

int["ADD_TAB_SDW_LOG_DELETE"]: Set to 1 if deletions are logged. Otherwise,
set to 0. No longer used in version 2.0.

int["ADD_TAB_SDW_LOG_SELECT"]: Set to 1 if selects are logged. Otherwise,
set to 0. No longer used in version 2.0.

int["ADD_TAB_SDW_MAX_LENGTH"]: Set the maximum length of the log. No
longer used in version 2.0.

int["ADD_TAB_SDW_AUTO_DELETE"]: Set to 1 if the log should be automatically
deleted when the table is deleted. No longer used in version 2.0.

string["ADD_TAB_PLG_UID"]: Unique ID of the table's plugin, if it exists.

string["DBS_UID"]: Unique ID of the database connection used by the table.
Set to "workflow" for the wf_<WORKSPACE> database and "rp" for the rp_<WORKSPACE> database.

string["PRO_UID"]: If a report table, the unique ID of the process which
contains the report table. For PM Tables, set to "" (empty string).

string["ADD_TAB_TYPE"]: Type of report table, which can be "GRID" or "NORMAL". If a PM Table, then "" (empty string).

string["ADD_TAB_GRID"]: If a grid report table, then the name of the
grid object (which is generally the grid name in camel case with spaces removed concatenated with the
word "Object"), followed by a dash and the grid DynaForm's unique ID. For example, a grid
named "Clients Grid" might be stored as "clientsGridObject-2426857374f3d2647f1ef11072861555".

string["ADD_TAB_TAG"]: Tags to identify the table. In version 2.0, this
is always "" (empty string).

AppNotes class

Case notes can be created, updated and deleted using the AppNotes class (and its parent class BaseAppNotes) which is defined in the file workflow/engine/classes/model/AppNotes.php and needs to be imported with require_once() before using the class. Case Notes are stored the wf_<WORKSPACE>.APP_NOTES table in the database. Note that AppNotes do not have a primary key, so they do not have a Load() method.

AppNotes::postNewNote()

The postNewNote() method creates a new case note in the specified case.

string$appUid: The unique ID of the case where the new note will be posted. Note that this parameter is not restricted by role based access control, so this can be any case.

string$usrUid: The unique ID of the user who will post the note. Note that this parameter is not restricted by role based access control, so this can be any user.

string$noteContent: The content of the note, which can contain HTML markup. The content should be passed through PHP's addslashes() function, so that it can be inserted in the database without problems.

boolean$notify: Optional. Set to true to send an email notification with the content of the new note.

string$noteAvailability: Optional. Set to "PUBLIC" if every user can see the case note or set to "PRIVATE" if only people who have rights to open the case can view it. Note that "PUBLIC" is not very public, since only people who can see the case in a list under the HOME menu will be able to actually view it.

string$noteRecipients: Optional. By default, notifications will be sent to all users who have participated in the case if $notify is set to true. To send the notification to different people, enter a list of email addresses, which are separated by commas ",".

string$noteType: Optional. Set to "USER" to specify that the note was posted by a user.

variant$noteDate: Optional. The date and time of the note, which is set to the current date and time by default. To set a different date and time, either enter a date-time string understood by strtotime() or a PHP timestamp.

AppNotes::getNotesList()

AppNotes::getNotesList() searches for all the notes for a specified case which a specified user has right to see and returns an array with a Criteria object and array of information about all the case notes.

Content class

The text associated with a ProcessMaker object can be looked up using the Content class which is defined in the file workflow/engine/classes/model/Content.php. The text for ProcessMaker objects is stored in the wf_<WORKSPACE>.CONTENT table in the database.

Content::load()

The Load() method returns the text associated with a specified ProcessMaker object, such as its title, description, comment, etc. In version 2.X, this method can also be used to return the translation for a specified language, but in version 3.X, translations no longer work.

string$conCategory: The category of content, such as 'DYN_TITLE', 'APP_DOC_FILENAME'. For a complete list of categories, see Finding ProcessMaker Objects.

string$ConParent: For all objects except the files uploaded to Input Document and Output Documents, this is set to "" (an empty string). If the $conCategory is "APP_DOC_FILENAME", "APP_DOC_TITLE" or "APP_DOC_COMMENT" then this parameter is set to the version number of the file, so the first version is "1", the second version is "2", etc.

string$conId: The unique ID of the ProcessMaker object, which consists of 32 hexadecimal characters, such as "69738725456a802d97e2eb7008185603".

string$conLangRecipients: Set to the ISO code of the language, such as "en" (English), "es" (Spanish), "fr-FR" (French from France), "pt-BR" (Portuguese from Brazil) or "zh-CN" (Chinese from Mainland China). For a list of the available languages see Translations. If set to "" (an empty string), then it will return the first record found in the CONTENT table regardless of the language. If a record doesn't exist in the CONTENT table for the specified language, then a new record will automatically added to the CONTENT table for the language. Its content is copied from another record with the same UID, and its text will be returned.Note:In version 3.X, there are no translations, so set it to "".

Return Value:
Returns the text for the specified unique ID (which is stored in the CONTENT.CON_VALUE field in the database). If the UID can't be found, then an empty string is returned.

Example:
Get the title for a DynaForm with the UID "12816611256a0006a028ab7006995270" in English and its Spanish translation:

Base Propel Classes

Most ProcessMaker classes (which are used to represent objects stored in database tables) are inherited from Propel's abstract base classes which define the common methods and the member variables and constants. Each ProcessMaker class has a corresponding base class are named BaseCLASS. For example: BaseAppNotes, BaseTriggers, BaseUsers, etc. In addition, each Peer class has a corresponding base Peer class named BaseCLASSPeer. For example: BaseAppNotesPeer, BaseTriggersPeer, BaseUsersPeer, etc.

Some of the commonly-used base class methods and member variables/constants are listed below. If needing a complete list, it is recommended to read the source code of the base classes.

Common Base Class Variables

The base classes commonly have the following protected variables (which can only be accessed by inherited classes).

protected static object$peer: Holds the Peer class for this class. For example: AppNotesPeer

protected boolean$alreadyInSave: Flag to prevent endless validation loop, if this object is referenced by another object which falls in this transaction.

protected boolean$alreadyInValidation: Flag to prevent endless validation loop, if this object is referenced by another object which falls in this transaction.

protected variant$field: Each field in the database has a corresponding protected member variable, whose name is in lowercase. For example, the APP_UID field would be $app_uid and the NOTE_ORIGIN_OBJ field would be $note_origin_obj. Because these member variables are protected, they are generally accessed through their corresponding getter and setter methods.

Field Getters and Setters

Each field in the base class has a corresponding getter and setter method to access it. These are generally named with camel case. For example, the value of the APP_UID field (whose protected member variable is named $app_uid) is retrieved with the getAppUid() method:

variantBaseCLASS::getAppUid()

Likewise, its value is set with the setAppUid() method:

voidBaseCLASS::getAppUid(variant $v)

Notes that these getter and setter methods will only work on classes which have been instantiated. Also note that the setter methods only change the value of protected member variables in the class instance. In order for those changes to be committed to the database, call the save() or doUpdate() methods.

For example, to get and set the APP_UID for an AppNotes instance:

require_once'classes/model/AppNotes.php';$note=new AppNotes();$result=$note->getNotesList(@@APPLICATION,@@USER_LOGGED,0,100);$note= AppNotesPeer::doSelectOne($result['criteria']);if(isset($n)){//get the APP_UID:$caseId=$note->getAppUid();//set the APP_UID:$note->getAppUid('1307127704f3be85d694d37070686091');//Update the Case Note in the database:$note->save();}

Return Value:An associative array whose keys are the field names or field positions (depending upon the $keyType) and the values are the field values.

BaseCLASS::save()

Commits an object to the database. If it already exists, then it updates the existing record in the database. Otherwise, it inserts a new record. The commit is wrapped in a transaction, so if an exception occurs, it will automatically be rolled back. Make sure that the object's member variables are populated before calling this method.

intBaseCLASS::save(Connection $con = null)

Parameters:

Connection$con: Optional. The connection to use. If set to null, then it will automatically create a Propel connection to the default database for the class.

Return Value:Returns the number of affected rows. If an exception occurs, returns null and a PropelException will be thrown. Check @@__ERROR__ or $_SESSION['__ERROR__'] for the exception message.

BaseCLASS::delete()

Deletes an object from the database. The deletion is wrapped in a transaction, so if an exception occurs, it will automatically be rolled back. Make sure that the object's member variables are populated before calling this method.

voidBaseCLASS::delete(Connection $con = null)

Parameters:

Connection$con: Optional. The connection to use. If set to null, then it will automatically create a Propel connection to the default database for the class.

Return Value:None. If an exception occurs, a PropelException will be thrown. Check @@__ERROR__ or $_SESSION['__ERROR__'] for the exception message.

BaseCLASS::validate()

Validates the objects modified field values and all objects related to this table. If $columns is specified, then only those columns are validated.

booleanBaseCLASS::validate(variant $columns = null)

Parameters:

variant$columns: Optional. A string with a column name or an array of column names. If set to NULL, then all columns are checked.

Return Value:Returns true if all specified columns pass validation. If one or more fail, then returns false.

BaseCLASS::getByName()

Retrieves the value of a specified field from the object. The field can be indicated by its PHP property name, its column name, its field name or its position number in an array.

BaseCLASS::setByName()

Sets the value of a specified field in the object. The field can be indicated by its PHP property name, its column name, its field name or its position number in an array. Note that this method only sets the value of the objects member variable. Call BaseCLASS::save() to commit this value to the database.

BaseCLASS::setByPosition()

Sets the value of a specified field in the object by its position in the database table. Note that this method only sets the value of the objects member variable. Call BaseCLASS::save() to commit this value to the database.

BaseCLASSPeer::doCount()

Criteria$criteria: The Criteria object used to build the SELECT statement.

boolean$distinct: Optional. Set to true if each row should be distinct. By default set to false.

Connection$con: Optional. The connection to use. If set to null, then it will automatically create a Propel connection to the default database for the class.

Return Value:Returns the number found by the SELECT statement. If an exception occurs, returns null and a PropelException will be thrown. Check @@__ERROR__ or $_SESSION['__ERROR__'] for the exception message.

BaseCLASSPeer::doSelect()

Selects object(s) from the database based upon a Criteria object.

arrayBaseCLASSPeer::doSelect(Criteria $criteria, Connection $con)

Parameters:

Criteria$criteria: The Criteria object used to build the SELECT statement.

Connection$con: The connection to use. If set to null, then it will automatically create a Propel connection to the default database for the class.

Return Value:Returns an array of CLASS objects. If an exception occurs, returns null and a PropelException will be thrown. Check @@__ERROR__ or $_SESSION['__ERROR__'] for the exception message.

BaseCLASSPeer::doSelectOne()

Selects one object from the database based upon a Criteria object.

ResultSetBaseCLASSPeer::doSelect(Criteria $criteria, Connection $con)

Parameters:

Criteria$criteria: The Criteria object used to build the SELECT statement.

Connection$con: The connection to use. If set to null, then it will automatically create a Propel connection to the default database for the class.

Return Value:Returns the first CLASS object found by the SELECT statement. If an exception occurs, returns null and a PropelException will be thrown. Check @@__ERROR__ or $_SESSION['__ERROR__'] for the exception message.

BaseCLASSPeer::doSelectRS()

Selects object(s) from the database based upon a Criteria object and returns a ResultSet object.