Questions and discussion about using ProcessMaker: user interface, running cases & functionality
By gregkuhnert
#785406
I have a grid that includes a data field. When I send notifications using template on assignment, the email generated includes the date entered in the form, but it also includes the time that the form was submitted. I am using 3.0.1.7.

Is this expected behaviour?
By daBoomKing
#785407
Hi Greg

See here: http://wiki.processmaker.com/3.0/Proces ... Date.28.29

See also "Example Sending Variables to a Template" in http://wiki.processmaker.com/3.0/Proces ... sage.28.29

Here is an example of my code:

$oldDate = @@myOldDate;
$newDate = formatDate($oldDate, 'yyyy-mm-dd', 'en');
PMFSendMessage(@@APPLICATION, "blah@blah", "blah@blah" , "blah@blah", "", "Something happened on {$newDate}", "test.html", array(''), array(''), true, 0, "");

Cheers
Andrew
By gregkuhnert
#785520
Hi Andrew.

I was trying to do a notification that was defined using only the HTML template, and going to task right-click -> Properties -> Notifications. No ability to use triggers with that default notification method.

Yes, I can write code to do that - but that adds complexity. This should work out of the box...

Greg.
User avatar
By amosbatto
#785530
Some people want the date at the time when it was originally set, so we can't please everyone.

Create the following trigger and set it to execute right before the point in your process where you send your email:
Code: Select all
@@mydate = getCurrentDate() . ' ' . getCurrentTime();
Where "mydate" is the datetime variable.

Then the new date will be used in the email. If you are setting the date inside a grid field, you have to do something like this:
Code: Select all
if (is_array(@=mygrid) {
   foreach (@=mygrid as $aRow) {
      $aRow['mydate'] = getCurrentDate() . ' ' . getCurrentTime();
   }
} 
Where "mygrid" is the grid variable and "mydate" is the ID of the datetime field inside the grid.
By gregkuhnert
#785532
Hi Amos.

I fully understand your code. But let me ask this:
Code: Select all
Default: false
See http://momentjs.com/docs/#/displaying/format/ for valid datetime formats. If only the date is included in the format then the time picker will not be displayed.

Examples:
dddd, MMMM Do YYYY, h:mm:ss a >> "Sunday, February 14th 2010, 3:25:50 pm"
ddd, hA >> "Sun, 3PM"
YYYY MM DD >> "Valid date"
The above is from the help text for the format string in the date/time field. I used YYYY-MM-DD. Why would the date picker ignore my format string and add any time details in there at all?

And more importantly, let me ask one more question. The slogan of Processmaker is "Workflow Simplified". I want a date. I want the date to go into a template. Why should I need to write code to strip out the time that I never wanted in the field in the first place?

No offence, but your code is a workaround, not a solution to the oversight in how the date picker does something totally unexpected.
User avatar
By amosbatto
#785567
@gregkuhnert,
Sorry I didn't understand your question. As erpnedir notes, use @#mydate in your template if you want the full datetime used internally by PM and use @#mydate_label if you just want the the formatted date that you have configured. No trigger code is required.
By NAlvarado
#815459
I have a similar question n regards to formatting a date. In the Dynaform the date is in format DD-MMM-YYYY but when inserting into Oracle via a trigger, I need the format to be mm/dd/yyyy. What is the best way to do this? I tried a few things but nothing gets inserted.

$oldDate = @@initiatePaymentDate;
$newDate = formatDate($oldDate, 'yyyy-mm-dd', 'en');
User avatar
By amosbatto
#815470
NAlvarado wrote: I have a similar question n regards to formatting a date. In the Dynaform the date is in format DD-MMM-YYYY but when inserting into Oracle via a trigger, I need the format to be mm/dd/yyyy. What is the best way to do this? I tried a few things but nothing gets inserted.
Code: Select all
$oldDate = @@initiatePaymentDate;
$newDate = formatDate($oldDate, 'yyyy-mm-dd', 'en');
You can use this trigger code:
Code: Select all
if (@@initiatePaymentDate) {
   $a = preg_split('/[\- ]/', @@initiatePaymentDate);
   $newDate = $a[1].'/'.$a[2].'/'.$a[0];
}
By NAlvarado
#815570
I'm having trouble converting it to DD-MON-YYYY, from YYYY-MM-DD. I've tried a few things but receive an error when I load it into Oracle. If I try loading it as the value in the DynaForm (although it shows as DD-MON-YYYY on the form) it inserts as YYYY-MM-DD in Oracle.

Being the best in the started business is the obje[…]

Winzo is a popular and unique game on the mobile p[…]

Cannot create process using templets

Real details. The problem was solved by effect!

However, it is essential to use it responsibly and[…]