Questions and discussion about using ProcessMaker: user interface, running cases & functionality
By hdobbs
#813314
I am building a webentry dynaform in 3.2 and am trying to populate some of the fields. I used to be able to edit the dynaform php file and change the array that is sent to the form from a blank array to an array that had the values I wanted to populate the fields. Now in 3.2 the $G_PUBLISH->AddContent is replaced by $a->printWebEntry which doesn't have anywhere for me to send the values. Is there a way that I can populate the fields in 3.2?
User avatar
By amosbatto
#813320
This one took me a while to figure out. You can add custom PHP code to be executed before the Web Entry form is generated by editing your processmaker/shared/sites/{workspace}/public/{process-id}/{step-id}.php file.

Any variables that you want to pass to the Dynaform when it is generated need to be set as in the ['APP_DATA'] element in the array that is passed to the new pmDynaform() object.

Here is a code example. Change the code from:
Code: Select all
<?php
global $_DBArray;
if (!isset($_DBArray)) {
  $_DBArray = array();
}
$_SESSION["PROCESS"] = "5384231895a8df57b0b5bd0064144777";
$_SESSION["CURRENT_DYN_UID"] = "2809796415a8df5b576c316091834096";
$G_PUBLISH = new Publisher();
G::LoadClass("pmDynaform");
$a = new pmDynaform(array("CURRENT_DYNAFORM" => "2809796415a8df5b576c316091834096")); 
To:
Code: Select all
<?php
G::LoadClass("pmFunctions");

$ratingList = array(
    array('',     "--select--"),
    array("good", "Good"      ),
    array("bad",  "Bad"       ),
    array("ugly", "Ugly"      )
);

$userList = array();
$sql = "SELECT USR_UID, CONCAT(USR_FIRSTNAME, ' ', USR_LASTNAME) AS FULL_NAME FROM USERS";
$aUsers = executeQuery($sql);

foreach ($aUsers as $aUser) {
    $userList[] = array($aUser['USR_UID'], $aUser['FULL_NAME']);
}

$sql2 = "SELECT PRO_TITLE AS processTitle FROM PROCESS";
$processList = executeQuery($sql2);

$aCaseVars = array(
   'ratingList' => $ratingList,
   'userList'   => $userList,
   'processList'=> $processList
);

global $_DBArray;
if (!isset($_DBArray)) {
  $_DBArray = array();
}
$_SESSION["PROCESS"] = "5384231895a8df57b0b5bd0064144777";
$_SESSION["CURRENT_DYN_UID"] = "2809796415a8df5b576c316091834096";
$G_PUBLISH = new Publisher();
G::LoadClass("pmDynaform");
$a = new pmDynaform(array("CURRENT_DYNAFORM" => "2809796415a8df5b576c316091834096", "APP_DATA" => $aCaseVars)); 
This code sets 3 variables which populate the list of options in two dropdown boxes and the rows in a grid in the Web Entry form. To test it, import this process:
(30.95 KiB) Downloaded 219 times
By hdobbs
#813413
So I thought everything was working fine but I realized that the processmaker/shared/sites/{workspace}/public/{process-id}/{step-id}.php file keeps getting over written. Not by something I am doing. It seams to happen every couple of hours. So any changes I make don't last.

Any idea what is going on? And how I can stop it from getting over written.
User avatar
By amosbatto
#813417
Every time you right click on the starting event in the process and select "Web Entry" from the context menu and open it for editing, you are overwriting the file. The best solution is to add your custom code in the same directory in a separate file named "mycustomcode.php" and then import it into the processmaker/shared/sites/{workspace}/public/{process-id}/{step-id}.php file with this line:
Code: Select all
require_once "mycustomcode.php";
That way you only have to rewrite that one line.

DO we have to pay tax for trade https://www.getfir[…]

Mosquito Zapper Reviews

https://www.facebook.com/sammosquitozapper https:[…]

https://www.facebook.com/sammosquitozapper https:[…]

Are you looking for a simple method to import EML […]