Yetiforcecrm: Error when i am trying to add new entry [bug]

Created on 25 Mar 2020  ·  10Comments  ·  Source: YetiForceCompany/YetiForceCRM

Hello all,
Version : 5.3.0 pack 1

I got this error when i am trying to add a new entry in.

error

🐛 bug 👮‍♂️ VerificationRequired

All 10 comments

As i see, the entry is created, but every time i add one, the error appears, even tough the entry is saved.

I have the same error (5.3 SP1) after upgrading.
Sales invoice module.

yeti błąd po aktu

Anyone ?

I have updated to the 3rd version of 5.3 but its not fixed yet.

+1

vendor/yetiforce/yii2/db/Schema.php(674)
#0 vendor/yetiforce/yii2/db/Command.php(1295): yii\db\Schema->convertException(Object(PDOException), 'INSERT INTO `u_...')
#1 vendor/yetiforce/yii2/db/Command.php(1091): yii\db\Command->internalExecute('INSERT INTO `u_...')
#2 app/Record.php(250): yii\db\Command->execute()
#3 modules/Vtiger/handlers/RecordLabelUpdater.php(19): App\Record::updateLabelOnSave(Object(Leads_Record_Model))
#4 app/EventHandler.php(323): Vtiger_RecordLabelUpdater_Handler->entityAfterSave(Object(App\EventHandler))
#5 modules/Vtiger/models/Record.php(503): App\EventHandler->trigger('EntityAfterSave')
#6 modules/Leads/models/Record.php(40): Vtiger_Record_Model->save()
#7 modules/com_vtiger_workflow/tasks/VTUpdateFieldsTask.php(70): Leads_Record_Model->save()
#8 modules/com_vtiger_workflow/Workflow.php(232): VTUpdateFieldsTask->doTask(Object(Leads_Record_Model))
#9 modules/Vtiger/handlers/Workflow.php(138): Workflow->performTasks(Object(Leads_Record_Model))
#10 modules/Vtiger/handlers/Workflow.php(57): Vtiger_Workflow_Handler->performTasks(Object(App\EventHandler), Array)
#11 app/EventHandler.php(323): Vtiger_Workflow_Handler->entityAfterSave(Object(App\EventHandler))
#12 modules/Vtiger/models/Record.php(503): App\EventHandler->trigger('EntityAfterSave')
#13 modules/Leads/models/Record.php(40): Vtiger_Record_Model->save()
#14 modules/Vtiger/actions/Save.php(101): Leads_Record_Model->save()
#15 modules/Vtiger/actions/Save.php(74): Vtiger_Save_Action->saveRecord(Object(App\Request))
#16 include/main/WebUI.php(187): Vtiger_Save_Action->process(Object(App\Request))
#17 index.php(28): Vtiger_WebUI->process(Object(App\Request))
#18 {main}

@mariuszkrzaczkowski
Somehow when you click save it executing below code

$db->createCommand()->insert('u_#__crmentity_label', ['crmid' => $recordModel->getId(), 'label' => $label])->execute();

5 Times which results in error, so far i were not able to find foreach function or another reason why its behaving like that.

I have changed the table "__crmentity_label" to test table and recorded the result video

2020-03-27_16-07-51.zip

@mariuszkrzaczkowski

the issue is only with VTUpdateFieldsTask

recordModel->save();
breaking the workflow .....

In app/Record.php at line 249 the INSERT is performed if $recordModel->isNew() method returns true. The problem is that at that point, the record had been already saved but the isNew flag had not been reset so, even if the record had been added, YetiForce "thinks" it's still a new record that needs to be added. When the record is saved for the first time the isNew should be turned to false.

I have not enought knowledge about Yetiforce and vtiger codebase to modify a so core functionality, so I ended up adding a simple straightforward patch. In app/Record.php at line 249 I changed
if ($recordModel->isNew())
in
if ($recordModel->isNew() && $recordModel->getId() === null)
so the record is not inserted twice.
I tested it on my environment and seems to work: no error at all, record appears correctly saved.
Waiting to know if this is a good point or this can compromise something.

@zazy - thank you very much for the fix. I will try it right now.

@zazy - thank you again. It is working.

i changed it like you said and it fixed it , thanks alot !!!

Was this page helpful?
0 / 5 - 0 ratings