[Vtigercrm-developers] Date format issue in Workflow Function

Alan Lord alanslists at gmail.com
Wed May 15 11:26:46 UTC 2013


This is really odd...

(vtiger 5.4.0)

I have created a custom workflow function that, when triggered, creates 
a bunch of related records that contain a date. It uses the webservices 
vtws_create API to build the new records.

When I edit a triggering record in Edit View, the workflow works fine. 
Period.

When I edit a field in a triggering record using the Ajax edit however, 
the vtws_create is messing up the date formatting.

In the UK we use d-m-Y as our normal display for dates.

In my workflow function all dates are formatted Y-m-d. But at the final 
hurdle, depending on whether I used EditView or Ajax, the insert 
function called from vtws_create messes up the date format and sets it 
back to the UK standard which MySQL doesn't like. (If I change Admin's 
date format setting to YYYY-mm-dd in the user settings then it works, 
but this hardly a solution IMHO).

Looking at the logs shows I think where this all going wrong...

In an EditView edit I see:
> Wed May 15 11:48:07 2013,138 [22121] DEBUG index - Entering getValidDBInsertDateValue(16-10-2012) method ...
> Wed May 15 11:48:07 2013,138 [22121] DEBUG index - Exiting getValidDBInsertDateValue method ...

Whereas in AjaxEdit I don't see those two lines but I do see a call to:

> Entering getDisplayDate(2012-12-14) method ...

which returns it as 14-12-2012 and tries to write this into the database!

So I've worked around it by adding a

> $current_user->date_format = "yyyy-mm-dd";

In my workflow function just before the vtws_create call. This feels a 
bit sucky...

Anyone fancy suggesting a proper fix?

Cheers

Al



More information about the vtigercrm-developers mailing list