[Vtigercrm-developers] add entity with certain crmid

Sukhdev Mohan s.mohan at myti.it
Thu Jun 24 07:10:21 GMT 2021


Hi Tony,

You can do that but it’s a bit tricky:

1. Start transaction
2. Insert into crmentity, cementity_seq, account, accountscf, bill address and all the other with that ID

This is how upload is done by the way, with the only difference that you check for the first available crmid.

Inserting manually will cause you to update the crmentity_seq table which means that if the id you selected isn’t the next free one you’ll have many free id that won’t be used.

Sample snippet:
$freeId = 107;
$adb->startTransaction();
$crmentityResult = $adb->pquery("INSERT INTO vtiger_crmentity (crmid, setype, description, createdtime, smcreatorid, smownerid) VALUES (?, 'Account', '', NOW(), '1', '1')",
   [$freeId]
);

if(!$crmentityResult) {
 $adb->completeTransaction();
 echo "DB ERROR: couldn't insert into crmentity";
}

// go ahead


Best Regards,
Sukhdev Mohan | Software Developer

Cel. (+39) 320 7020345
On 24 Jun 2021, 06:04 +0200, Tony Sandman <tonysandman999 at gmail.com>, wrote:
> Got need to add an account with certain crmid (id not occupied).
> Can you advise on some shortcut ladies/gents?
>
> T
> _______________________________________________
> http://www.vtiger.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.vtigercrm.com/pipermail/vtigercrm-developers/attachments/20210624/4102f6f9/attachment-0001.html>


More information about the vtigercrm-developers mailing list