[Vtigercrm-developers] Creating related modules fields

ardi zeneli zeneliiardi at gmail.com
Mon Oct 26 13:57:16 GMT 2015


Hello,

i am trying to create a relation between the modules "Sales Orders" and
"Campaigns" using a uitype 10 field. For this i am using the code below,
but it doesn't seem to work correctly. I have tried modifying the code by
replacing "get_related_list" with "get_dependents_list", or even from the
database in the vtiger_relatedlists table, modifying the name from
get_related lists to get_dependents or get_salesorders, as other existing
relations but still nothing. The problem is that when i select a campaign
from the uitype10 field in the Sales Order, the result isn't shown in the
related list in the Campaigns module, only when i select it manually from
the related list in the Campaigns module the record is added to the list.
The relation is added also in the vtiger_fieldmodulerel with the correct
field id of the uitype 10 field.
Is there anything else that i can check, or another way to do this?

Thanks

<?php
// Turn on debugging level
$Vtiger_Utils_Log = true;
require_once('vtlib/Vtiger/Module.php');
require_once('vtlib/Vtiger/Block.php');
require_once('vtlib/Vtiger/Field.php');
$module = Vtiger_Module::getInstance('SalesOrder');
$block = Vtiger_Block::getInstance('LBL_SO_INFORMATION',$module);
$field = new Vtiger_Field();
$field->label = 'Related Campaign';
$field->name = 'campagna_related';
$field->column = 'campagna_related';
$field->columntype = 'VARCHAR(255)';
$field->uitype = 10;
$field->typeofdata = 'V~O';
$block->addField($field);
$block->save($module);
$field->setRelatedModules(Array('Campaigns'));

$module = Vtiger_Module::getInstance('Campaigns');
$module->setRelatedList(Vtiger_Module::getInstance('SalesOrder'),
'SalesOrder',
Array('ADD'),'get_related_list');
?>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.vtigercrm.com/pipermail/vtigercrm-developers/attachments/20151026/8fa160df/attachment.html>


More information about the vtigercrm-developers mailing list