[Vtigercrm-developers] Correct way to Delete Entity records and related

Sukhdev Mohan s.mohan at myti.it
Thu Mar 3 14:42:01 GMT 2022


As you can see, that is how vtws_delete() is called. It basically marks the entity record as deleted in vtiger_crmentity table. To delete permanently you need to empty the the bin.

Another way you can achieve delete is by calling the delete() method on the entity model.

Since there is no official documentation you need to check the code and try to simulate it. For documents please have a look at delete() in <root>/modules/Documents/actions/Folder.php file, here vtiger uses the EntityModel for Documents and calls the delete() method on it. Depending on whether you are working with id’s or the `objects` you can choose one or the other alternative. In any case you need to empty the bin to permanently delete something. Also do have a look at Delete.php file in module/Vtiger/actions, I’m sure you’’find something useful for your case :D

Buona fortuna
Il gio 3 mar 2022, 15:15 Tiziano Morgia <tiziano.morgia at gmail.com> ha scritto:
> I have found this:
> include_once 'include/Webservices/Delete.php';try {        $wsid = vtws_getWebserviceEntityId('Leads', 'CRMID') // Module_Webservice_ID x CRM_ID        vtws_delete($wsid, $current_user);} catch (WebServiceException $ex) {        echo $ex->getMessage();}
> On this url => https://community.vtiger.com/help/vtigercrm/developers/server-apis.html
> Is it the right way?
> For attachments, I imagined there was a special function because I had noticed that deleting a document from the vTiger module also removed the underlying file.
>
>
> > Il giorno gio 3 mar 2022 alle ore 13:36 Sukhdev Mohan <s.mohan at myti.it> ha scritto:
> > > Use vtws_delete() twice to delete from db.
> > > To physically delete the attachments just get the path and file name from db and then proceed to delete the files via script.
> > >
> > > > Il gio 3 mar 2022, 13:29 Tiziano Morgia <tiziano.morgia at gmail.com> ha scritto:
> > > > > Hi to all,
> > > > >    we have a vTiger instance that contains a high number of custom modules on which we import, through php scripts, a high number of data including attachments.
> > > > >    We therefore need to cancel the following types of data when importing data and / or through scheduled activities:
> > > > > - Records of custom modules
> > > > > - Attachments to the records of the previous point (including associated files on disk)
> > > > > - Contain the number of records of the change history (if active on the module). For example, keep the last 10 changes for each single entity.
> > > > >
> > > > > We can delete it directly using db query ($adb->query("DELETE FROM xxx");) but I think that there is a correct way, using the vtlib or similar, to delete the three types of data, or not?
> > > > > I tried to search but find nothing about it.
> > > > > Has anyone had a similar need?
> > > > >
> > > > > Thanks in advance,
> > > > > Tiziano
> > > > >
> > > > > _______________________________________________
> > > > > http://www.vtiger.com/
> > > _______________________________________________
> > > http://www.vtiger.com/
>
>
> --
> .::Tiziano::.
> _______________________________________________
> http://www.vtiger.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.vtigercrm.com/pipermail/vtigercrm-developers/attachments/20220303/481a1802/attachment-0001.html>


More information about the vtigercrm-developers mailing list