Hi fardon,
This is one of my solutions, using AJAX.
Documentation:
http://wiki.processmaker.com/index.php/ ... _DynaForms
1.) Create a database where you will get the info for the grid (if not yet created). Below is a screenshot of my example created database schema and table.
db.PNG (30.19 KiB) Viewed 5686 times
2.) Create a query.php script and store it in your /opt/processmaker/workflow/public_html
Code: Select all<?php
//path to the file containing connection info for MySQL:
//include 'password.php'; //i comment it out because i am too lazy to create another script
//employee_id is the one going to be triggering the independent field
header('Content-type: application/json');
if (isset($_GET['employee_id'])) {
$q = $_GET['employee_id'];
}
else {
die ('[]'); //return an empty array
}
$con = mysql_connect('localhost', 'root', 'kamote1234') or die('[]'); //this is your database credential
mysql_select_db("mike_db", $con); //this is the db
$sql = "SELECT FULL_NAME, HIRED_DATE, STARTING_SALARY from EMPLOYEES where EMP_ID = $q"; //this is the query
$result = mysql_query($sql) or die('[]');
$ret = '';
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
$ret .= (empty($ret) ? '' : ', ') .
"{ 'full_name' : '{$row['FULL_NAME']}', 'hired_date' : '{$row['HIRED_DATE']}' , 'salary' : '{$row['STARTING_SALARY']}' }"; //this will be the result in json
}
mysql_close($con);
die('[' . $ret . ']');
?>
3. Create a js script that will call the ajax
Code: Select all//this ajax is not perfect so please feel free to modify it anyway you want
$("#employee_id").setOnchange(doQuery);
function doQuery() {
var q = getFieldById("employee_id").getText();
if (window.XMLHttpRequest) // code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
else // code for IE5, IE6
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
var rows = eval( '(' + xmlhttp.responseText + ')' );
//var grd = getObject("clientsGrid");
for (var i = 0; i < rows.length; i++) {
$("#employee_info").setValue(rows[i].full_name,i+1 , 1);
$("#employee_info").setValue(rows[i].hired_date,i+1 , 2);
$("#employee_info").setValue(rows[i].salary,i+1 , 3);
}
}
}
xmlhttp.open("GET", "http://192.168.137.128:8080/query.php?employee_id="+q, true); //the 192.168.137.128:8080 is where i could access my PM
xmlhttp.send();
}
4.) here is a sample screenshot of my project that I also attach
screen.PNG (72.89 KiB) Viewed 5686 times
I hope this helps you in your problem