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 Gunna01
#794448
I have a grid with a datetime field called date

The grid name is called Travel_ItineraryDetails

How can I make it so when a user opens the case the @@date variable in the grid is set to todays date? The default date option does not have a 'today' option
#794495
Just do a trigger that executes before the grid open.
Code: Select all
@@current_date = date('Y-m-d H:i:s'');
In the dynaform, set the variable @@current_date as 'Hidden'. In the grid, set the value like:
Code: Select all
$("#Travel_ItineraryDetails").setValue($("#current_date").getValue(),row,col) //where row = line and col=column number
#794496
stevensi1018 wrote:Just do a trigger that executes before the grid open.
Code: Select all
@@current_date = date('Y-m-d H:i:s'');
Remove the extra quotation mark at the end of the trigger code and set the trigger to fire before the DynaForm:
Code: Select all
@@currentDate = date('Y-m-d H:i:s');
Create a hidden field in your DynaForm associated with the "currentDate" variable.

If you want today's date to automatically be inserted whenever a new row is added, then use this JavaScript code:
Code: Select all
var curDate = $("#currentDate").getValue();
var nRows = $("#myGrid").getNumberRows();
var col = 3; //set to the column number in grid which has datetime field

//set the default date in any existing rows where the datetime field is empty when the grid loads:
for (var i = 1; i <= nRows; i++) {
   if ($("#myGrid").getValue(i, col) == '') { 
      $("#myGrid").setValue(curDate, i, col); 
   }
}

//set the default date in any new rows added in the grid:
$("#myGrid").onAddRow( function(aNewRow, oGrid, rowIndex) {
     $("#myGrid").setValue(curDate, rowIndex, col); 
});
#794497
Oh, I see a much easier way to do this.
Create the trigger as explained in the previous post and put @@currentDate in the "default value" property of the datetime field in the grid:
setDefaultDateInGrid.png
setDefaultDateInGrid.png (43.12 KiB) Viewed 5112 times

Hello. For rental housing, there are software solu[…]

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[…]