Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
AJAX editing leads to empty date fields on aftersave event
I have implemented an aftersave event on SalesOrders. When a salesorder is saved, the related assets are updated to change some values depending on the SalesOrder. Here is the code that does that:

PHP Code:
            if ($soData['sostatus'] == 'Niet geleverd' || $soData['sostatus'] == 'Ingepland') {
$r $adb->pquery("SELECT * FROM vtiger_crmentityrel WHERE crmid = ? AND relmodule = ?", array($soId'Assets'));
                if (
$adb->num_rows($r) > 0) {
                    while (
$row $adb->fetch_array($r)) {
// Update the asset "keurstatus"
$ass = new Assets();
$ass->retrieve_entity_info($row['relcrmid'], 'Assets');
$ass->id $row['relcrmid'];
$ass->mode 'edit';
$ass->column_fields['cf_966'] = $new_asset_status// Adjust custom field ID
$handler vtws_getModuleHandlerFromName('Assets'$current_user);
$meta $handler->getMeta();
$ass->column_fields DataTransform::sanitizeRetrieveEntityInfo($ass->column_fields$meta);

The weird thing is, when I perform the action by doing a full edit on the SalesOrder, it works as expected. But when I do an inline edit on the SalesOrder, all the date fields in the asset (custom and regular) get set to '0000-00-00'. This happens after the last line of code (I output the column fields to a temp file and tested that in various places in the proces). I've never experienced this before. Do I need to set some $_REQUEST value maybe?
I suppose that if the user you test with has ISO date format (Y-m-d) it works correctly. If that is the case, I'd say you have to unset the ajxaction REQUEST varaible:

PHP Code:
$_REQUEST['ajxaction'] == 'DETAILVIEW' 

when in AJAX inline edit mode this variable is set to indicate that all the values are set to database values. In other words, in inline edit mode the application only expects the field being saved to be in the user format, all the rest have been directly read from the database and do not need conversion. Since you are converting them, when MySQL see the value it is in the format of the user and blanks it. At least that is what I am suspecting.

try and

PHP Code:

in your handler and let me know how it goes.
Thought it would be something along those lines, thanks! I'll try and keep you posted.

Forum Jump:

Users browsing this thread: 1 Guest(s)