[Vtigercrm-developers] Delete records from recycle bin
Alan Lord
alanslists at gmail.com
Thu Jul 17 08:21:04 GMT 2025
Thanks for the follow up Vincenzo,
Can we not collaborate on a project in Gitlab to get a merge request
ready for proper testing?
As for your last comment about related fields, in the Cloud CRM they do
clear the related fields. I just deleted an organisation that was in the
Contact's Organisation field and the field was cleared. When I restore
the record, the field is re-populated.
I assumed that was was all stored in the "vtiger_relatedlists_rb" table
but even though it is referenced in CRMEntity (see unlinkDependencies
method) it never seems to have any data in it...
Cheers
Al
On 16/07/2025 15:11, Vincenzo Bruno wrote:
> The issue with*"orphan" entities*is a significant one in*Vtiger*.
>
> The core framework does*not*check related entities, leaving
> them*orphaned*when deleting or*unlinking*the parent.
>
> For example, deleting a*Project*leaves its*Project Tasks*orphaned. The
> same applies to its*comments, documents, activities, etc.*
>
> We implemented a*workaround*for this with a*custom handler*that catches|
> beforedelete|and|beforeunrelate|events. If entities are related via
> a*mandatory field*, then*delete*and*unrelate*operations are*blocked*. In
> the previous example, the*Project*field in*Project Task*entities is
> mandatory, so deleting a*Project*with at least*one task*is prevented.
>
> The next step is to*enable forced deletion*by adding a*"delete on
> cascade"*checkbox. However, we are concerned about potential*circular
> dependencies*in custom modules or complex entity configurations.
>
> All of this*functionality*should be added to*Vtiger's core*and should*at
> least*work in*core modules*. Our current code is a*"quick &
> dirty"*solution that works for us, but it needs*cleanup and
> generalization*before being submitted as a*Merge Request (MR)*.
>
> Moreover, there is another issue with the*Recycle Bin*when activated:
>
> *
>
> Deleting a parent entity marks it as*deleted*, but*related fields
> are not cleared*until the Recycle Bin is emptied.
>
> *
>
> For example, in*Projects*, you still see a*link to the deleted
> Project*in a*Task*, but clicking on it throws an error.
>
>
>
>
>
>
> Il 16/07/25 11:31, Alan Lord ha scritto:
>> Anyone got any thoughts on cleaning the crmentityrel table?
>>
>> I think maybe this would be better to include in the delete code in
>> the recycle bin model, e.g.
>>
>> "DELETE FROM vtiger_crmentityrel WHERE (module = ? AND crmid = ?) OR
>> (relmodule = ? AND relcrmid = ?)"
>>
>> Are there any potential issues with removing rows from this table?
>> Otherwise it is just going to keep on growing as far as I can tell...
>>
>> But then we get into the others too: seactivityrel,
>>
>> Cheers
>>
>> Al
More information about the vtigercrm-developers
mailing list