<font size="6"><b><span style="color: rgb(255, 0, 0);">File</span></b></font>:   vtiger_crm/data/CRMEntity.php<br><br> 100             if($on_focus-&gt;IsCustomModule &amp;&amp; method_exists($on_focus, &#39;save_related_module&#39;)) {<br>
 101                 $with_module = $module;<br> 102                 $with_crmid = $this-&gt;id;<br> 103                 $on_focus-&gt;save_related_module(<br> 104                    <span style="color: rgb(255, 0, 0);"> $for_module, $for_crmid, $with_module, $with_crmid</span>);<br>
 105             }<br><br>sometimes , <span style="color: rgb(255, 0, 0);">$for_crmid would be Empty or </span><span style="color: rgb(255, 0, 0);">Equate with $with_crmid</span> (depends on the $_REQUEST[&#39;return_id&#39;]).<br>
<br><font size="6"><b><span style="color: rgb(255, 0, 0);">Description:</span></b></font><br><br>I made a CustomModule and created a record. when I duplicate the record and save , it Occurs an Error.<br><br>(mysql): SELECT crmid FROM vtiger_crmentityrel WHERE crmid = &#39;&#39; AND module = &#39;MBOrders&#39; AND relcrmid = 175 AND relmodule = &#39;MBOrders&#39;  <br>
(mysql): INSERT INTO vtiger_crmentityrel(crmid, module, relcrmid, relmodule) VALUES(&#39;&#39;,&#39;MBOrders&#39;,175,&#39;MBOrders&#39;)  <br><br><font size="6"><b><span style="color: rgb(255, 0, 0);">Solution:</span></b></font><br>
<br> 100             if( <span style="color: rgb(0, 51, 0); background-color: rgb(153, 255, 153);">!empty($for_module) &amp;&amp; !empty($for_crmid) &amp;&amp; </span>$on_focus-&gt;IsCustomModule &amp;&amp; method_exists($on_focus, &#39;save_related_module&#39;)) {<br>
 101                 $with_module = $module;<br> 102                 $with_crmid = $this-&gt;id;<br>                     <span style="color: rgb(0, 51, 0); background-color: rgb(153, 255, 153);">  if($for_crmid != $with_crmid &amp;&amp; $for_module != $with_module)</span><br>
 103                 $on_focus-&gt;save_related_module(<br> 104                    <span style="color: rgb(255, 0, 0);"> $for_module, $for_crmid, $with_module, $with_crmid</span>);<br> 105             }<br>