[Vtigercrm-developers] vtiger 5.2.0 Projects Module

Pedro Simoes pedro.m.simoes at gmail.com
Tue Jul 13 08:48:18 PDT 2010


Al,

Adding a uitype 10 field will give you a n:1 relationship between
Projects:Contacts, which is the opposite of what you are trying to do.

(and btw, I think you would have to use
"$fieldInstance->setRelatedModules(Array('Contacts'));" for your
example to work)

(and btw2: "$fieldInstance->unsetRelatedModules(Array('Contacts'));
$fieldInstance->delete();" should clear the field)

What you are looking for is a 1:n relationship.

Here's an example to add a 1:n relationship between Projects:Assets

<?php

// Just a bit of HTML formatting
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">';

echo '<html><head><title>vtlib Module Script</title>';
echo '<style type="text/css">@import url("themes/softed/style.css");br
{ display: block; margin: 2px; }</style>';
echo '</head><body class=small style="font-size: 12px; margin: 2px;
padding: 2px;">';
echo '<a href="index.php"><img
src="themes/softed/images/vtiger-crm.gif" alt="vtiger CRM"
title="vtiger CRM" border=0></a><hr style=
"height: 1px">';

// Turn on debugging level
$Vtiger_Utils_Log = true;

include_once('vtlib/Vtiger/Menu.php');
include_once('vtlib/Vtiger/Module.php');

//Relate projects with Assets 1:n
$moduleaccount = Vtiger_Module::getInstance('Assets');
$moduleaccount->setRelatedList(Vtiger_Module::getInstance('Project'),
'Project','');

echo '</body></html>';
?>


On 01/07/10 14:59, Alan Lord (News) wrote:
>* On 01/07/10 07:58, Alan Lord (News) wrote:*>*    *>>* On 30/06/10 17:27, Joe Bordes wrote:*>>*      *>>>* uitype 10 and setRelatedList*>>>* Have a read here: http://crmevolutivo.com/wiki/doku.php?id=vtlibrelated*>>>*        *>>* Thanks Joe,*>>**>>* That looks like just the ticket ;-)*>>*      *>* OK - Been playing with this a bit.*>**>* Nearly got it right I think... But how can I delete a field I've added?*>* I now have two :-) I do not see a delField() function.*>**>* I did this in a quick script:*>**>* // Get Module Objects*>* $project = Vtiger_Module::getInstance('Project');*>* $contacts = Vtiger_Module::getInstance('Contacts');*>**>* // Get Main Block*>* $proj_info_block = Vtiger_Block::getInstance('LBL_PROJECT_INFORMATION',*>* $project);*>**>* // Create and add a UI Type 10 (Popup) Field*>* $fieldInstance = new Vtiger_Field();*>* $fieldInstance->name = 'Contact';*>* $fieldInstance->uitype = 10;*>* $fieldInstance->setRelatedModules('Contacts');*>**>* $proj_info_block->addField($fieldInstance);*>**>* // Add a 1:n relationship between $project&  $contacts*>* $project->setRelatedList($contacts, 'header',*>* Array('ADD'),'get_dependents_list');*>**>**>* Which "nearly" works.*>**>* I have a new UI Type 10 field in the Project Module, but there is an*>* empty "Related To" picklist and clicking on the plus sign brings up the*>* box but with the error "Module name is missing. Please check the module*>* name."*>**>* Incidentally, adding this field, seems to make it more a 1:1*>* relationship and I'd need to add "n" fields.*>**>* Am I being thick?*>**>* Sorry.*>**>* Al*>**>**>*    *>>* Cheers*>>**>>* Al*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.vtigercrm.com/pipermail/vtigercrm-developers/attachments/20100713/3abccf0c/attachment-0002.html 


More information about the vtigercrm-developers mailing list