I haven't checked in Oracle or Postgresql, but in MySQL and MS SQL Server, datetime fields use the format "YYYY-MM-DD HH:MM:SS", just like in ProcessMaker, so you don't have to transform them to insert them in a database.
You have a grid associated with the variable "contractList" which has the following fields:
"contractName" (textbox), "startDate" (datetime), "dueDate" (datetime)
And you have a database table named "CONTRACTS" with the fields:
CASE_NO (integer), CONTRACT_NAME (varchar), START_DATE (datetime), DUE_DATE (datetime)
Then, use trigger code like this:
Code: Select all//set to ID of your database connection or comment out if using a PM Table:
$db = 'XXXXXXXXXXXXXXXXXXXX';
if (isset(@=contractList) and !empty(@=contractList)) {
foreach (@=contractList as $aRow) {
$caseNo = @@APP_NUMBER;
//use addslashes() instead of mysql_real_escape_string() if not using MySQL:
$contractName = mysql_real_escape_string($aRow['contractName']);
$startDate = $aRow['startDate'];
$dueDate = $aRow['dueDate'];
$sql = "INSERT INTO PMT_DATES (CASE_NO, CONTRACT_NAME, START_DATE, DUE_DATE)
VALUES ($caseNo, '$contractName', '$startDate', 'dueDate')";
@@result = executeQuery($sql, $db); //don't include $db if using a PM Table
}
}
Set your trigger to fire after the DynaForm containing the grid. See:
http://wiki.processmaker.com/3.0/Proces ... uery.28.29