Reputation: 1
Did anyone try this?
I have a custom module I created a field next visit, I want to make an event after saving my record in my custom module based on next visit field date. here's the following code tried.
public function process(Vtiger_Request $request) {
try {
$CustomSaveEvents= $this->saveAppointmentRecord();
} catch (Exception $e) {
throw new Exception($e->getMessage());
}
}
public function saveAppointmentRecord() {
try {
$linkModule ="Events";
$recordModel1 = Vtiger_Record_Model::getCleanInstance($linkModule);
$recordModel1->set('subject', "Sample");
$recordModel1->set('mentorid',"6411");
$recordModel1->set('apprenticeid',"10849");
$recordModel1->set('due_date', '2022-10-24');
$recordModel1->set('time_end','2022-10-24');
$recordModel1->set('mode', 'create');
$recordModel1->save();
$this->savedRecordId = $recordModel1->getId();
return $recordModel1;
}catch (Exception $e) {
throw new Exception($e->getMessage());
}
}
But it didn't work. any can help me? Thank you in advance!
calendar will show new record
Upvotes: 0
Views: 437
Reputation: 1922
I have a better solution that does not require coding. You can use Workflows to create an Event on save the event. Here is the link to which you can refer to configure the workflow in CRM. This Video might not fulfill your exact requirements, but you can refer to understand how Workflow configuration works.
Upvotes: -1
Reputation: 122
I have recently done something similar, but with the "Products" and "Documents" modules.
The crm was hanging when executing save(), until I realized that it was caused by some aftersave events, the ones related to VTEntitydelta.
My solution was to disable these events before save():
$desactivaHandlers = "UPDATE vtiger_eventhandlers SET is_active = 0 WHERE dependent_on LIKE '[\"VTEntityDelta\"]'";
$result = $adb->pquery($desactivaHandlers);
And reactivate it again after the save():
$reactivaHandlers = "UPDATE vtiger_eventhandlers SET is_active = 1 WHERE dependent_on LIKE '[\"VTEntityDelta\"]'";
$result = $adb->pquery($reactivaHandlers);
Hope it helps!
Upvotes: 0