<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->IsCustomModule && method_exists($on_focus, 'save_related_module')) {<br>
101 $with_module = $module;<br> 102 $with_crmid = $this->id;<br> 103 $on_focus->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['return_id']).<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 = '' AND module = 'MBOrders' AND relcrmid = 175 AND relmodule = 'MBOrders' <br>
(mysql): INSERT INTO vtiger_crmentityrel(crmid, module, relcrmid, relmodule) VALUES('','MBOrders',175,'MBOrders') <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) && !empty($for_crmid) && </span>$on_focus->IsCustomModule && method_exists($on_focus, 'save_related_module')) {<br>
101 $with_module = $module;<br> 102 $with_crmid = $this->id;<br> <span style="color: rgb(0, 51, 0); background-color: rgb(153, 255, 153);"> if($for_crmid != $with_crmid && $for_module != $with_module)</span><br>
103 $on_focus->save_related_module(<br> 104 <span style="color: rgb(255, 0, 0);"> $for_module, $for_crmid, $with_module, $with_crmid</span>);<br> 105 }<br>