Questions and discussion about developing processes and programming in PHP, JavaScript, web services & REST API.
Forum rules: Please search to see if a question has already asked before creating a new topic. Please don't post the same question in multiple forums.
By DEEPAKD
#789696
Hi ALL


How to insert Date & Time Field from Grid to database
(Note - In Grid I Am Only Selecting date But in database I want it with Current time which is not empty )



Thanks
Deepak
User avatar
By amosbatto
#789729
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

Experience heightened pleasure with Cenforce 100 M[…]

Get an instant solution to move emails to MBOX for[…]

Most Demanding OST to PST Converter

The most demanding OST to PST Converter is TrijaT[…]

Betvisa clone scripts are pre-built software solut[…]