Questions and discussion about using ProcessMaker: user interface, running cases & functionality
By cosyxu
#816254
Hi Amo,

According to this,
https://wiki.processmaker.com/3.0/Panel ... e_DynaForm.

Is it possible to query from the database and pass the result into the Dyanform to show in this data table?

I have tried to add a trigger before the Dyanform, but how can I pass the data from trigger into the Dyanform?
Code: Select all
$query = 'SELECT id, name FROM History';
$result = executeQuery($query);
@@caseList = json_encode($result);
how can I translate this @@caseList into an array in the Dyanform and then pass into the data table?

Any ideas?
Thanks,
Yuan
User avatar
By amosbatto
#816275
Create a hidden field associated with the variable "caseListJson" in your Dynaform.

Then add the following trigger to your process:
Code: Select all
$aCaseList = array();
$query = 'SELECT id, name FROM History';
$result = executeQuery($query);

foreach ($result as $aRow) {
     $aCaseList[] = array($aRow['id'], $aRow['name']);
}
@@caseListJson = json_encode($result);
Set this trigger to fire before the DynaForm.

Then add this JavaScript to your DynaForm:
Code: Select all
var aCases = [];
var casesJson = $("#caseListJson").getValue();
if (casesJson != '') {
     aCases = JSON.parse(casesJson);
}
    
$(document).ready(function() {
    $('#example').DataTable( {
        data: aCases,
        columns: [
            { title: "ID" },
            { title: "Name" }
        ]
    } );
} );
By cosyxu
#816276
amosbatto wrote: Tue Sep 25, 2018 8:43 pm Create a hidden field associated with the variable "caseListJson" in your Dynaform.

Then add the following trigger to your process:
Code: Select all
$aCaseList = array();
$query = 'SELECT id, name FROM History';
$result = executeQuery($query);

foreach ($result as $aRow) {
     $aCaseList[] = array($aRow['id'], $aRow['name']);
}
@@caseListJson = json_encode($result);
Set this trigger to fire before the DynaForm.

Then add this JavaScript to your DynaForm:
Code: Select all
var aCases = [];
var casesJson = $("#caseListJson").getValue();
if (casesJson != '') {
     aCases = JSON.parse(casesJson);
}
    
$(document).ready(function() {
    $('#example').DataTable( {
        data: aCases,
        columns: [
            { title: "ID" },
            { title: "Name" }
        ]
    } );
} );
Hi Amo,

Thanks for the solution.

When you mentioned "hidden field" did you mean by "Hidden Control" in the Dyanform or a hidden textbox?

Thanks,
Yuan

Web3 development encompasses creating decentralize[…]

The Upland Clone Script, offered by Dappsfirm, rep[…]

Dappsfirm offers a bet365 clone script that mirror[…]

🚀 Tauchen Sie mit Immediate Alora AI in die Welt d[…]