DynaForm Endpoints
The current methods implemented for the Dynaform resources in the ProcessMaker API designer are listed below:
- DynaForm Endpoints
- Get Dynaform List:
GET project/{prj_uid}/dynaforms
- Get Dynaform:
GET project/{prj_uid}/dynaform/{dyn_uid}
- Get Field List in Grid:
GET project/{prj_uid}/dynaform/{dyn_uid}/grid/{grd_name}/field-definitions
- Get Field in Grid:
GET project/{prj_uid}/dynaform/{dyn_uid}/grid/{grd_name}/field-definition/{fld_id}
- Create DynaForm:
POST project/{prj_uid}/dynaform
- Create Dynaform from Copy/Import:
POST project/{prj_uid}/dynaform
- Create Dynaform from PM Table:
POST project/{prj_uid}/dynaform
- Update Dynaform:
PUT project/{prj_uid}/dynaform/{dyn_uid}
- Delete Dynaform:
DELETE project/{prj_uid}/dynaform/{dyn_uid}
Dynaform resources:
Name | Description | Type | Value |
---|---|---|---|
dyn_uid | Dynaform UID | String | "9541049475298f190420f51086854718" (string of 32 characters) |
dyn_title | Dynaform title | String | "Title…" |
dyn_description | Dynaform description | String | "Description…" |
dyn_type | Dynaform type | String | "xmlform", "grid" (unique values) |
dyn_content | Dynaform content | String | String with the content. |
dyn_version | Dynaform version | Integer | 1. Old version. 2. New version |
copy_import ** | Dynaform data to copy/import | Object | Object with the following attributes: prj_uid and dyn_uid |
copy_import . prj_uid ** | Process UID | String | "7389179125176dac806d205065699622" (string of 32 characters) |
copy_import . dyn_uid ** | Dynaform UID to Copy / Import | String | "77941473952b49c65a01a80041727578" (string of 32 characters) |
pmtable ** | PM Table data | Object | Object with the following attributes: tab_uid and fields |
pmtable . tab_uid ** | PMTable UID | String | "72249773552b84ded1d8aa4036518645" (string of 32 characters) |
pmtable . fields ** | Define the primary key field to register the PM Table | Object | Object array with the following attributes: fld_name and pro_variable |
pmtable . fields . fld_name ** | Primary field of the PM Table | String | "ID" |
pmtable . fields . pro_variable ** | Variable name whose value will be stored in the primary key field | String | "@#APPLICATION" |
Note: (**) Defines only one value: copy_import or pmtable; if both variables are defined, an error will be shown.
Information about each method is written in the sections below:
Get Dynaform List: GET project/{prj_uid}/dynaforms
Gets the list of Dynaforms in a project.
GET /api/1.0/{workspace}/project/{prj_uid}/dynaforms
Parameters:
-
Name Type Description workspace String Workspace name prj_uid String Project UID
Result:
-
Type Description array Returns an array of Dynaforms objects
Example:
Response
Content-Type: application/json
[
{
"dyn_uid": "2074240775261579834c597006169172",
"dyn_title": "User data",
"dyn_description": "User data...",
"dyn_type": "xmlform"
},
{
"dyn_uid": "84564134152b20cb3efa430060666501",
"dyn_title": "Demo grid1",
"dyn_description": "Demo grid1 DESCRIPTION...",
"dyn_type": "grid"
},
{
"dyn_uid": "17796063752b32090a0e950049957998",
"dyn_title": "My DynaForm1",
"dyn_description": "My DynaForm1 DESCRIPTION",
"dyn_type": "xmlform"
}
]
Get Dynaform: GET project/{prj_uid}/dynaform/{dyn_uid}
Gets a single Dynaform from a project.
GET /api/1.0/{workspace}/project/{prj_uid}/dynaform/{dyn_uid}
Parameters:
-
Name Type Description workspace String Workspace name prj_uid String Project UID dyn_uid String Dynaform UID
Result:
-
Type Description object Returns an array of Dynaform objects
Example:
Response
Content-Type: application/json
{
"dyn_uid": "2074240775261579834c597006169172",
"dyn_title": "User data",
"dyn_description": "User data...",
"dyn_type": "xmlform"
}
Get Field List in Grid: GET project/{prj_uid}/dynaform/{dyn_uid}/grid/{grd_name}/field-definitions
Gets the list of fields found in a specified grid.
GET /api/1.0/{workspace}/project/{prj_uid}/dynaform/{dyn_uid}/grid/{grd_name}/field-definitions
URL Parameters:
-
Name Type Description Example workspace String Workspace name. /api/1.0/workflow/project/798659366573140bc117490080056441/ dynaform/406442383573140df944390011262710/grid/ clientList/field-definitions prj_uid String Unique ID of the project, which can be found in the @@PROCESS
system variable in the Debugger./api/1.0/workflow/project/798659366573140bc117490080056441/ dynaform/406442383573140df944390011262710/grid/ clientList/field-definitions dyn_uid String Unique ID of the Dynaform that holds the grid, which can be found by clicking on the border of the DynaForm and looking at the id property. /api/1.0/workflow/project/798659366573140bc117490080056441/ dynaform/406442383573140df944390011262710/grid/ clientList/field-definitions grd_name String The name of the variable which is associated with the grid. Note that it is not possible to retrieve grids that aren't associated with a variable. /api/1.0/workflow/project/798659366573140bc117490080056441/ dynaform/406442383573140df944390011262710/grid/ clientList/field-definitions
Result:
-
If successful, the HTTP status code is set to
200
and an array of objects is returned, which contain the attributes of the fields in the specified grid. The attributes vary according to the type of field. To learn more, see the Available Attributes of DynaForm controls and Editing DynaForm's JSON code.
Example:
-
Response
200 (OK)
[
{
"type": "text",
"variable": "",
"var_uid": "",
"dataType": "",
"protectedValue": false,
"id": "clientName",
"name": "clientName",
"label": "Client Name",
"defaultValue": "",
"placeholder": "",
"hint": "",
"required": false,
"textTransform": "none",
...
}
{
"type": "datetime",
"variable": "",
"var_uid": "",
"dataType": "",
"protectedValue": false,
"id": "contractDate",
"name": "contractDate",
"label": "Contract Date",
"placeholder": "",
"hint": "",
"required": false,
"mode": "parent",
"format": "YYYY-MM-DD",
"dayViewHeaderFormat":"MMMM YYYY",
"extraFormats": false,
"stepping": 1,
"minDate": "",
...
}
]
PHP Example:
-
The following code retrieves the field list for a grid whose variable is named "clientList", and prints a list of the attributes for each field in the grid.
$oToken = pmRestLogin('YOXQRMHAMMMKSOENEDENDFQDTJTGTUUS', '32667560556abe5142235e0090500305', 'mary', 'p@s5w0rD');
if (!isset($oToken) or !isset($oToken->access_token)) {
die("Error: Can't access ProcessMaker REST");
}
$gridName = 'clientList';
$dynaformId = '406442383573140df944390011262710';
$projectId = '798659366573140bc117490080056441';
$url = "/api/1.0/workflow/project/$projectId/dynaform/$dynaformId/grid/$gridName/field-definitions";
$oRet = pmRestRequest("GET", $url, null, $oToken->access_token);
if ($oRet->status != 200) {
print_r($oRet);
die;
}
print "<pre>"; //if displaying in a web page
foreach($oRet->response as $oField) {
print "{\n";
foreach($oField as $key => $value) {
print " $key => $value\n";
}
print "}\n";
}
Get Field in Grid: GET project/{prj_uid}/dynaform/{dyn_uid}/grid/{grd_name}/field-definition/{fld_id}
Gets the attributes of a field in a grid.
-
GET /api/1.0/{workspace}/project/{prj_uid}/dynaform/{dyn_uid}/grid/{grd_name}/field-definition/{fld_id}
URL Parameters:
-
Name Type Description Example workspace String Workspace name. /api/1.0/workflow/project/798659366573140bc117490080056441/ dynaform/406442383573140df944390011262710/grid/ clientList/field-definition/address prj_uid String Unique ID of the project, which can be found in the @@PROCESS
system variable in the Debugger./api/1.0/workflow/project/798659366573140bc117490080056441/ dynaform/406442383573140df944390011262710/grid/ clientList/field-definition/address dyn_uid String Unique ID of the Dynaform that holds the grid, which can be found by clicking on the border of the DynaForm and looking at the id property. /api/1.0/workflow/project/798659366573140bc117490080056441/ dynaform/406442383573140df944390011262710/grid/ clientList/field-definition/address grd_name String The name of the variable which is associated with the grid. Note that it is not possible to retrieve grids that aren't associated with a variable. /api/1.0/workflow/project/798659366573140bc117490080056441/ dynaform/406442383573140df944390011262710/grid/ clientList/field-definition/address fld_id String The id of a field inside a grid. /api/1.0/workflow/project/798659366573140bc117490080056441/ dynaform/406442383573140df944390011262710/grid/ clientList/field-definition/address
Result:
-
If successful, the HTTP status code is set to
200
and an object is returned, which contain the attributes of the grid field. The attributes vary according to the type of field. To learn more, see the Available Attributes of DynaForm controls and Editing DynaForm's JSON code.
Example:
-
Response
200 (OK)
{
"type": "text",
"variable": "",
"var_uid": "",
"dataType": "",
"protectedValue": false,
"id": "clientName",
"name": "clientName",
"label": "Client Name",
"defaultValue": "",
"placeholder": "",
"hint": "",
"required": false,
"textTransform": "none",
"validate": "",
"validateMessage": "",
"maxLength": 1000,
"formula": "",
"mode": "parent",
"operation": "",
"datasource": "database",
"dbConnection": "workflow",
"dbConnectionLabel":"PM Database",
"sql": "",
"dataVariable": "",
"columnWidth": "30",
"width": 100,
"title": "Client Name"
}
PHP Example:
-
The following code prints out the attributes of a field with the ID "clientName" found in a grid whose variable is named "clientList".
$oToken = pmRestLogin('YOXQRMHAMMMKSOENEDENDFQDTJTGTUUS', '32667560556abe5142235e0090500305', 'mary', 'p@s5w0rD');
if (!isset($oToken) or !isset($oToken->access_token)) {
die("Error: Can't access ProcessMaker REST");
}
$gridName = 'clientList';
$fieldId = 'clientName';
$dynaformId = '406442383573140df944390011262710';
$projectId = '798659366573140bc117490080056441';
$url = "/api/1.0/workflow/project/$projectId/dynaform/$dynaformId/grid/$gridName/field-definition/$fieldId";
$oRet = pmRestRequest("GET", $url, null, $oToken->access_token);
if ($oRet->status == 200) {
print "<pre>"; //if in web page
foreach($oRet->response as $key => $value) {
"$key => $value\n";
}
}
Create DynaForm: POST project/{prj_uid}/dynaform
Normal creation of a DynaForm.
POST /api/1.0/{workspace}/project/{prj_uid}/dynaform
Parameters:
-
Name Type Description workspace String Workspace name prj_uid String Project UID
Required Fields:
-
Name Type Description dyn_title String Dynaform title dyn_type String Dynaform type, which is always "xmlform". dyn_version Integer Dynaform version which is 1
for a classic Dynaform based on XML or2
for a responsive Dynaform based on JSON.
Optional Fields:
-
Name Type Description dyn_description String Dynaform description dyn_content String The XML or JSON code for the Dynaform. This can be found either by exporting a Dynaform as a .json file or by copying the content from the DYNAFORM.DYN_CONTENT field in the database. If importing JSON, all the whitespace needs to be removed.
TIP: If needing to edit a Dynaform's content, go to http://jsonviewer.stack.hu and paste the JSON code into the editing window. Then, click on Format to get an editable version of the JSON with spacing. When done editing, click on Remove white space to remove the spacing. Then, copy the JSON code into a text editor and search for each"
and replace it with\"
so that all the Dynaform's code will be contained in a single string.
Result:
-
Type Description object Returns an object with the new dynaform information and the attribute: "dyn_uid" If the
dyn_content
is included, then new unique IDs will be generated for the Dynaform and its variables when it is imported. If thedyn_title
anddyn_description
were specified, then they will be inserted in the Dynaform's code, replacing the original title and description.
Example:
Request
{
"dyn_title": "Billing Form",
"dyn_description": "Form to bill the client",
"dyn_type": "xmlform",
"dyn_version": 2,
"dyn_content": "{\"name\":\"Product Info\",\"description\":\"\",\"items\":[{\"type\":\"form\",\"variable\":\"\",\"var_uid\":\"\",\"dataType\":\"\",\"id\":\"1352098365c0efd6c21b2d9037373693\",\"name\":\"Product Info\",\"description\":\"\",\"mode\":\"edit\",\"script\":{\"type\":\"js\",\"code\":\"\"},\"language\":\"en\",\"externalLibs\":\"\",\"printable\":false,\"items\":[[{\"type\":\"text\",\"variable\":\"productName\",\"var_uid\":\"5032625705c0efd7c9ba579087277592\",\"dataType\":\"string\",\"protectedValue\":false,\"id\":\"productName\",\"name\":\"productName\",\"label\":\"Product Name\",\"defaultValue\":\"\",\"placeholder\":\"\",\"hint\":\"\",\"required\":false,\"requiredFieldErrorMessage\":\"\",\"textTransform\":\"none\",\"validate\":\"\",\"validateMessage\":\"\",\"maxLength\":1000,\"formula\":\"\",\"mode\":\"parent\",\"operation\":\"\",\"dbConnection\":\"workflow\",\"dbConnectionLabel\":\"PM Database\",\"sql\":\"\",\"var_name\":\"productName\",\"colSpan\":12}],[{\"type\":\"multipleFile\",\"variable\":\"specFiles\",\"var_uid\":\"3466037925c0efd88a7b0e9026297065\",\"dataType\":\"multiplefile\",\"protectedValue\":false,\"id\":\"specFiles\",\"name\":\"specFiles\",\"label\":\"Spec Files\",\"inputDocument\":\"\",\"required\":false,\"requiredFieldErrorMessage\":\"\",\"dnd\":false,\"extensions\":\"*\",\"size\":1024,\"sizeUnity\":\"MB\",\"enableVersioning\":false,\"mode\":\"parent\",\"multiple\":false,\"inp_doc_uid\":\"\",\"var_name\":\"specFiles\",\"colSpan\":12}],[{\"type\":\"submit\",\"id\":\"submit0000000001\",\"name\":\"submit0000000001\",\"label\":\"Submit\",\"colSpan\":12}]],\"variables\":[{\"var_uid\":\"5032625705c0efd7c9ba579087277592\",\"prj_uid\":\"1841478345c0efd4edb4677090328834\",\"var_name\":\"productName\",\"var_field_type\":\"string\",\"var_field_size\":10,\"var_label\":\"string\",\"var_dbconnection\":\"workflow\",\"var_dbconnection_label\":\"PM Database\",\"var_sql\":\"\",\"var_null\":0,\"var_default\":\"\",\"var_accepted_values\":\"[]\",\"inp_doc_uid\":\"\"},{\"var_uid\":\"3466037925c0efd88a7b0e9026297065\",\"prj_uid\":\"1841478345c0efd4edb4677090328834\",\"var_name\":\"specFiles\",\"var_field_type\":\"multiplefile\",\"var_field_size\":10,\"var_label\":\"multiplefile\",\"var_dbconnection\":\"workflow\",\"var_dbconnection_label\":\"PM Database\",\"var_sql\":\"\",\"var_null\":0,\"var_default\":\"\",\"var_accepted_values\":\"[]\",\"inp_doc_uid\":\"\"}]}]}"
}
Response
{
"dyn_uid": "17796063752b32090a0e950049957998",
"dyn_title": "Billing Form",
"dyn_description": "Form to bill the client",
"dyn_type": "xmlform",
"dyn_version": 2,
"dyn_content": "{\"name\":\"Billing Form\",\"description\":\"Form to bill the client\",\"items\":[{\"type\":\"form\",\"variable\":\"\",\"var_uid\":\"\",\"dataType\":\"\",\"id\":\"17796063752b32090a0e950049957998\",\"name\":\"Product Info\",\"description\":\"\",\"mode\":\"edit\",\"script\":{\"type\":\"js\",\"code\":\"\"},\"language\":\"en\",\"externalLibs\":\"\",\"printable\":false,\"items\":[[{\"type\":\"text\",\"variable\":\"productName\",\"var_uid\":\"5032625705c0efd7c9ba579087277592\",\"dataType\":\"string\",\"protectedValue\":false,\"id\":\"productName\",\"name\":\"productName\",\"label\":\"Product Name\",\"defaultValue\":\"\",\"placeholder\":\"\",\"hint\":\"\",\"required\":false,\"requiredFieldErrorMessage\":\"\",\"textTransform\":\"none\",\"validate\":\"\",\"validateMessage\":\"\",\"maxLength\":1000,\"formula\":\"\",\"mode\":\"parent\",\"operation\":\"\",\"dbConnection\":\"workflow\",\"dbConnectionLabel\":\"PM Database\",\"sql\":\"\",\"var_name\":\"productName\",\"colSpan\":12}],[{\"type\":\"multipleFile\",\"variable\":\"specFiles\",\"var_uid\":\"3466037925c0efd88a7b0e9026297065\",\"dataType\":\"multiplefile\",\"protectedValue\":false,\"id\":\"specFiles\",\"name\":\"specFiles\",\"label\":\"Spec Files\",\"inputDocument\":\"\",\"required\":false,\"requiredFieldErrorMessage\":\"\",\"dnd\":false,\"extensions\":\"*\",\"size\":1024,\"sizeUnity\":\"MB\",\"enableVersioning\":false,\"mode\":\"parent\",\"multiple\":false,\"inp_doc_uid\":\"\",\"var_name\":\"specFiles\",\"colSpan\":12}],[{\"type\":\"submit\",\"id\":\"submit0000000001\",\"name\":\"submit0000000001\",\"label\":\"Submit\",\"colSpan\":12}]],\"variables\":[{\"var_uid\":\"5032625705c0efd7c9ba579087277592\",\"prj_uid\":\"1841478345c0efd4edb4677090328834\",\"var_name\":\"productName\",\"var_field_type\":\"string\",\"var_field_size\":10,\"var_label\":\"string\",\"var_dbconnection\":\"workflow\",\"var_dbconnection_label\":\"PM Database\",\"var_sql\":\"\",\"var_null\":0,\"var_default\":\"\",\"var_accepted_values\":\"[]\",\"inp_doc_uid\":\"\"},{\"var_uid\":\"3466037925c0efd88a7b0e9026297065\",\"prj_uid\":\"1841478345c0efd4edb4677090328834\",\"var_name\":\"specFiles\",\"var_field_type\":\"multiplefile\",\"var_field_size\":10,\"var_label\":\"multiplefile\",\"var_dbconnection\":\"workflow\",\"var_dbconnection_label\":\"PM Database\",\"var_sql\":\"\",\"var_null\":0,\"var_default\":\"\",\"var_accepted_values\":\"[]\",\"inp_doc_uid\":\"\"}]}]}"
}
PHP Example:
$aVars = array(
"dyn_title" => "Billing Form",
"dyn_description" => "Form to bill the client",
"dyn_type" => "xmlform",
"dyn_version" => 2,
"dyn_content" => $content
);
$json = json_encode($aVars);
$processId = '6784841035c2ee7cedbc9c4005687877';
$url = "http://example.com/api/1.0/workflow/project/$processId/dynaform";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
"Authorization: Bearer " . $accessToken,
'Content-Type: application/json',
'Content-Length: ' . strlen($json)
));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$oRet = json_decode(curl_exec($ch));
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
Create Dynaform from Copy/Import: POST project/{prj_uid}/dynaform
Creates a Dynaform using Copy/Import.
Permission:
- Users must have the PM_FACTORY permission assigned to their role to perform this action.
Structure:
POST /api/1.0/{workspace}/project/{prj_uid}/dynaform
Parameters:
-
Name Type Description workspace String Workspace name prj_uid String Project UID
Required Fields:
-
Name Type Description dyn_title String Dynaform title dyn_version Integer Dynaform version copy_import String Dynaform data to Copy/Import copy_import . prj_uid String Project UID copy_import . dyn_uid String Dynaform UID
Optional Fields:
-
Name Type Description dyn_description String Dynaform description dyn_content String Dynaform content
Result:
-
Type Description object Returns an object that contains information about the new Dynaform and the attribute: "dyn_uid"
Example:
Request
{
"dyn_title": "My DynaForm1",
"dyn_description": "My DynaForm1 DESCRIPTION",
"dyn_type": "xmlform",
"copy_import":
{
"prj_uid": "7389179125176dac806d205065699622",
"dyn_uid": "77941473952b49c65a01a80041727578"
}
}
Response
{
"dyn_uid": "17796063752b32090a0e950049957998",
"dyn_title": "My DynaForm1",
"dyn_description": "My DynaForm1 DESCRIPTION",
"dyn_type": "xmlform"
}
Create Dynaform from PM Table: POST project/{prj_uid}/dynaform
Creates a Dynaform using the fields in a PM table.
Permission:
- Users must have the PM_FACTORY permission assigned to their role to perform this action.
Structure:
POST /api/1.0/{workspace}/project/{prj_uid}/dynaform
Parameters:
-
Name Type Description workspace String Workspace name prj_uid String Project UID
Required Fields:
-
Name Type Description dyn_title String Dynaform title dyn_version Integer Dynaform version pmtable object PM Table data pmtable . tab_uid String PM Table UID pmtable . fields object Definition of the primary key to register in the PM Table
Optional Fields:
-
Name Type Description dyn_description String Dynaform description dyn_content String Dynaform content
Result:
-
Type Description object Returns an object that contains information about the new Dynaform and the attribute: "dyn_uid"
Example:
Request
{
"dyn_title": "My DynaForm1",
"dyn_description": "My DynaForm1 DESCRIPTION",
"dyn_type": "xmlform",
"pmtable":
{
"tab_uid": "72249773552b84ded1d8aa4036518645",
"fields": [
{
"fld_name": "ID",
"pro_variable": "@#APPLICATION"
}
]
}
}
Response
{
"dyn_uid": "17796063752b32090a0e950049957998",
"dyn_title": "My DynaForm1",
"dyn_description": "My DynaForm1 DESCRIPTION",
"dyn_type": "xmlform"
}
Update Dynaform: PUT project/{prj_uid}/dynaform/{dyn_uid}
Updates a Dynaform in a project.
Permission:
- Users must have the PM_FACTORY permission assigned to their role to perform this action.
Structure:
PUT /api/1.0/{workspace}/project/{prj_uid}/dynaform/{dyn_uid}
Parameters:
-
Name Type Description workspace String Workspace name prj_uid String Project UID dyn_uid String Dynaform UID
Optional Fields:
-
Name Type Description dyn_title String Dynaform title dynaform_description String Dynaform description dyn_type String Dynaform type dyn_version Integer Dynaform version dyn_content String Dynaform content
Result:
-
Type Description empty No return
Example:
Request
{
"dyn_title": "My DynaForm1…",
"dyn_description": "My DynaForm1 DESCRIPTION…",
"dyn_type": "xmlform"
}
Response
Delete Dynaform: DELETE project/{prj_uid}/dynaform/{dyn_uid}
Deletes a Dynaform in a project.
Permission:
- Users must have the PM_FACTORY permission assigned to their role to perform this action.
Structure:
DELETE /api/1.0/{workspace}/project/{prj_uid}/dynaform/{dyn_uid}
Parameters:
-
Name Type Description workspace String Workspace name prj_uid String Project UID dyn_uid String Dynaform UID
Result:
-
Type Description empty No return
Example:
Response