[Vtigercrm-developers] extends Contacts class - new relations
Alan Lord
alanslists at gmail.com
Thu Jun 17 10:19:28 GMT 2021
I presume you have created a UIType 10 field in your custom module for a
Contact reference?
e.g.:
$module = Vtiger_Module::getInstance('vulOrg');
$block = Vtiger_Block::getInstance('vulOrg Information', $module);
$field = Vtiger_Field::getInstance('contact_id', $module);
if ($field != false) {
$field->unsetRelatedModules(array('Contacts'));
$field->delete();
}
$field = new Vtiger_Field();
$field->name = 'contact_id';
$field->label = 'Contact';
$field->column = $field->name;
$field->columntype = 'INT(11)';
$field->uitype = 10;
$field->typeofdata = 'V~O';
$field->summaryfield = 1;
$field->masseditable = 0;
$block->addField($field);
$field->setRelatedModules(array('Contacts'));
Then you _should_ be able to use the standard method to create the
relatedList in the Contact module. e.g.:
$contacts = Vtiger_Module::getInstance('Contacts');
$field = Vtiger_Field::getInstance('contact_id', $module);
$contacts->unsetRelatedList($module, 'vulOrg', 'get_dependents_list');
$contacts->setRelatedList($module, 'vulOrg', array('ADD'),
'get_dependents_list', $field->id);
Something like that should do it.
This was from memory so might need tweaking.
Al
On 17/06/2021 11:05, omri yona wrote:
> Hello all,
>
> I try to do something without changing the vtiger core. Maybe you have
> any idea.
> My case:
> I have a custom module (module name: vulOrg) with a relations to the
> contacts module so now in the Contacts module I have a new tab to my
> custom module.
> To support this tab I need to change the contacts core file
> (modules/Contacts/Contacts.php)
> 1. set new function get_vulorg (like get_emails...) to find my relations
> record (can't use the basic get_related_list or get_dependents_list
> function)
> 2. add flow in unlinkRelationship function
>
> I manage to do what I want by changing the core file, but I don't like
> core changes.
>
> I would love to get any ideas on how to do it without changing the core.
>
> Thank you for your help,
> Omri
>
>
>
> _______________________________________________
> http://www.vtiger.com/
>
More information about the vtigercrm-developers
mailing list