Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
AJAX editing leads to empty date fields on aftersave event
#1
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);
                        
$ass->save('Assets');
                    }
                }
            } 

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?
Reply


Messages In This Thread
AJAX editing leads to empty date fields on aftersave event - Guido1982 - 10-25-2017, 05:25 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)