<meta http-equiv="content-type" content="text/html; charset=utf-8"><span class="Apple-style-span" style="font-family: &#39;Times New Roman&#39;; font-size: medium; "><pre>Al,</pre><pre>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.</pre>

<pre>(and btw, I think you would have to use &quot;$fieldInstance-&gt;setRelatedModules(Array(&#39;Contacts&#39;));&quot; for your example to work)</pre><pre>(and btw2: &quot;$fieldInstance-&gt;unsetRelatedModules(Array(&#39;Contacts&#39;)); $fieldInstance-&gt;delete();&quot; should clear the field)</pre>

<pre>What you are looking for is a 1:n relationship.</pre><pre>Here&#39;s an example to add a 1:n relationship between Projects:Assets</pre><pre>&lt;?php</pre><pre>// Just a bit of HTML formatting
echo &#39;&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot; &quot;<a href="http://www.w3.org/TR/html4/loose.dtd">http://www.w3.org/TR/html4/loose.dtd</a>&quot;&gt;&#39;;

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

// Turn on debugging level
$Vtiger_Utils_Log = true;

include_once(&#39;vtlib/Vtiger/Menu.php&#39;);
include_once(&#39;vtlib/Vtiger/Module.php&#39;);

//Relate projects with Assets 1:n
$moduleaccount = Vtiger_Module::getInstance(&#39;Assets&#39;);
$moduleaccount-&gt;setRelatedList(Vtiger_Module::getInstance(&#39;Project&#39;), &#39;Project&#39;,&#39;&#39;);

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