Questions and discussion about developing processes and programming in PHP, JavaScript, web services & REST API.
Forum rules: Please search to see if a question has already asked before creating a new topic. Please don't post the same question in multiple forums.
#822722
i wanna ask, how to create dynaform with dyn_content in rest api? i tried with postman always error (got err_message : "message": "<br />\n<b>Notice</b>: Undefined index: DYN_UID in <b>/opt/processmaker3.3.2/workflow/engine/src/ProcessMaker/BusinessModel/DynaForm.php</b> on line <b>1154</b><br />\n<br />\n<b>Notice</b>: Undefined index: $dynaFormUid in <b>/opt/processmaker3.3.2/workflow/engine/src/ProcessMaker/BusinessModel/DynaForm.php</b> on line <b>374</b><br />\n{\"error\":{\"code\":400,\"message\":\"Bad Request: The DynaForm with : does not exist.\"}}",
"status": 400)
but i tried create dynaform with form (label,textarea) and its work.
can anyone tell me how to fix this?
Attachments
photo_2019-02-04_10-33-31.jpg
Create Dynaform type normal.
photo_2019-02-04_10-33-31.jpg (58.08 KiB) Viewed 3926 times
#822850
but i still got this message :
{
"message": "<br />\n<b>Notice</b>: Undefined index: DYN_UID in <b>/opt/processmaker3.3.2/workflow/engine/src/ProcessMaker/BusinessModel/DynaForm.php</b> on line <b>1154</b><br />\n<br />\n<b>Notice</b>: Undefined index: $dynaFormUid in <b>/opt/processmaker3.3.2/workflow/engine/src/ProcessMaker/BusinessModel/DynaForm.php</b> on line <b>374</b><br />\n{\"error\":{\"code\":400,\"message\":\"Bad Request: The DynaForm with : does not exist.\"}}",
"status": 400
}
using processmaker 3.3.2, im try your example on https://wiki.processmaker.com/3.2/REST_ ... e_dynaform but still doesnt work.
Attachments
ice_screenshot_20190211-114404.png
ice_screenshot_20190211-114404.png (177.78 KiB) Viewed 3888 times
ice_screenshot_20190211-114404.png
ice_screenshot_20190211-114404.png (177.78 KiB) Viewed 3888 times
#822889
im trying using PHP while creating dynaform, but still got error message :
Array ( [message] =>
Notice: Undefined index: DYN_UID in /opt/processmaker3.3.2/workflow/engine/src/ProcessMaker/BusinessModel/DynaForm.php on line 1154
Notice: Undefined index: $dynaFormUid in /opt/processmaker3.3.2/workflow/engine/src/ProcessMaker/BusinessModel/DynaForm.php on line 374
{"error":{"code":400,"message":"Bad Request: The DynaForm with : does not exist."}} [status] => 400 )

and this is my code:
Code: Select all
$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":"1349269745c53c45612c467076876288","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":"1349269745c53c45612c467076876288","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":""}]}]}';

$accessToken = 'f5f1396a9302dd1f3696712ea32e18f962ed34dd';

$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 = '1349269745c53c45612c467076876288';
$url = "http://192.168.3.178:5001/w247/project/$processId/dynaform?type=normal";

$ch = curl_init($url); 
curl_setopt($ch, CURLOPT_HTTPHEADER, array( 
   "Authorization: OAuth oauth_token=" . $accessToken . "",
   "access_token: " . $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); 
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$response = curl_exec($ch);

$err = curl_error($ch);
$result = json_decode($response, true);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  print_r ($result);
}
please tell me how to fix it.
Attachments
ice_screenshot_20190212-164057.png
ice_screenshot_20190212-164057.png (69.65 KiB) Viewed 3876 times
#822902
Yes, I see the problem. It only works if the Dynaform already exists in the workspace.

I fixed it by editing workflow/engine/src/ProcessMaker/BusinessModel/Dynaform.php and changing lines 1150-1155 from:
Code: Select all
    public function throwExceptionIfTheColumnIdentifierIsNotValid($arrayData)
    {
        if (isset($arrayData['DYN_CONTENT'])) {
			$oldDynaform = $this->getDynaFormRecordByPk($arrayData['DYN_UID'], []);
			$oldGrids = PmDynaform::getGridsAndFields($oldDynaform['DYN_CONTENT']);
			$oldColumns = $this->getColumnsOfArrayGrids($oldGrids);
to:
Code: Select all
    public function throwExceptionIfTheColumnIdentifierIsNotValid($arrayData)
    {
        if (isset($arrayData['DYN_CONTENT'])) {
			if (!empty($arrayData['DYN_UID'])) { 
				$oldDynaform = $this->getDynaFormRecordByPk($arrayData['DYN_UID'], []);
				$oldGrids = PmDynaform::getGridsAndFields($oldDynaform['DYN_CONTENT']);
			}
			else {
				$oldGrids = PmDynaform::getGridsAndFields($arrayData['DYN_CONTENT']);
			}
			$oldColumns = $this->getColumnsOfArrayGrids($oldGrids);
If you make this code change, does it work for you?

Hello. For rental housing, there are software solu[…]

Experience heightened pleasure with Cenforce 100 M[…]

Get an instant solution to move emails to MBOX for[…]

Most Demanding OST to PST Converter

The most demanding OST to PST Converter is TrijaT[…]