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);
}