Questions and discussion about using ProcessMaker: user interface, running cases & functionality

Moderator: amosbatto

By azatrath
#815567
hi all,

there are 2 grids in my process, Grid1 contains purchases order in column one.

i need to generate Grid2 with sql function, but i need to get purchase orders from grid1.
Code: Select all
SELECT sp_orderno AS orderno, qty_desc AS kalite, rnk_palet AS palet, sum(ss_unitmsq) AS metrekare FROM cwv_000_orderlist WHERE ss_lineno>0 AND ( sp_orderno='$order1') group by sp_orderno,qty_desc,rnk_palet
sp_orderno is grid1 purchase order. i dont know how to search with grid. can you help me ?
Attachments
po.PNG
po.PNG (18.32 KiB) Viewed 184 times
User avatar
By amosbatto
#815576
If your Grid1 and Grid2 are in separate Dynaforms, then create a trigger to query the database between the two Dynaforms.

If your sp_orderno field is an integer, then you can use this trigger code:
Code: Select all
$db = 'abcdef1234567890abcdef1234567890'; //set to ID of Database Connection
$aOrderNums = array();
foreach (@=Grid1 as $aRow) {
    $aOrderNums[] = $aRow['orderNum'];
}
$sOrderNums = implode(', ', $aOrderNums);
$sql = "SELECT sp_orderno AS orderno, qty_desc AS kalite, rnk_palet AS palet, sum(ss_unitmsq) AS metrekare 
    FROM cwv_000_orderlist 
    WHERE ss_lineno>0 AND sp_orderno in ($sOrderNums) 
    group by sp_orderno, qty_desc, rnk_palet";
@=Grid2 = executeQuery($sql, $db);
If your sp_orderno field is a char field, then change to:
Code: Select all
$aOrderNums[] = "'" . addslashes($aRow['orderNum']) . "'";
Where Grid1 is associated with the variable "Grid1" and has a field with the ID "orderNum", and Grid2 is associated with the variable "Grid2".
Set this trigger to fire before the second DynaForm.

If you want Grid1 and Grid2 to be located in the same Dynaform, then you can't populate Grid2 with an SQL query, so you will need to use a button to submit the form, then fire the trigger after the Dynaform, and then use PMFRedirectToStep() to redisplay the form.

First of all, read this to understand the following example:
https://wiki.processmaker.com/3.2/Submi ... other_step

Then, add a hidden field with the ID "action" to your Dynaform and a submit button with the ID "searchButton". Then add the following JavaScript to your form:
Code: Select all
$("#action").setValue(''); //reset the "action" field when Dynaform loads

$("#searchButton").find("button").click( function() {
      $("#action").setValue('SEARCH');
});
Then, set the following trigger to fire after the DynaForm:
Code: Select all
$db = 'abcdef1234567890abcdef1234567890'; //set to ID of Database Connection
$dynaformId = '1234567890abcdef1234567890abcdef'; //set to ID of the Dynaform with grids

if (@@action == 'SEARCH') {
   $aOrderNums = array();
   foreach (@=Grid1 as $aRow) {
      $aOrderNums[] = $aRow['orderNum'];
   }
   $sOrderNums = implode(', ', $aOrderNums);
   $sql = "SELECT sp_orderno AS orderno, qty_desc AS kalite, rnk_palet AS palet, sum(ss_unitmsq) AS metrekare 
      FROM cwv_000_orderlist 
      WHERE ss_lineno>0 AND sp_orderno in ($sOrderNums) 
      group by sp_orderno, qty_desc, rnk_palet";
   @=Grid2 = executeQuery($sql, $db);
   PMFRedirectToStep(@@APPLICATION, @%INDEX, 'DYNAFORM', $dynaformId);
}

Nowadays this is one of the most common issues of […]

What version of MySQL are you using? If you are […]

I finally found some time to test this. What ver[…]

Hi! We try to use comminity edition for trial. If[…]