I'm using a code :
http://corebos.org/documentation/doku.php?id=en:devel:corebos_hooks:popup_open_hook:
srcmodule is ProjectMilestone
i have created a link between ProjectMilestone and Project Task : field parentid, uitype = 10
----------------
function productCaptureOnPhase(fromlink,fldname,MODULE,ID) {
var projectid = document.getElementById('projectid').value;
var phaseid = document.getElementById('phaseid').value;
var BasicSearch = '&projectid=' + projectid + '&phaseid=' + phaseid ;
var SpecialSearch = encodeURI(BasicSearch);
window.open("index.php?module=ProjectTask&action=Popup&html=Popup_picker&form=vtlibPopupView&forfield="+fldname+"&srcmodule="+MODULE+"&forrecord="+ID+SpecialSearch,"vtlibui10","width=680,height=602,resizable=0,scrollbars=0,top=150,left=200");
}
-------
when i popup and select the project task from Projectmilestone DetailView, the parentid is not set on the parent window
had to change the function as :
function vtlib_setvalue_from_popup(recordid,value,target_fieldname,formname) {
var ret = false;
if(window.opener.document.forms[formname]) {
var domnode_id = window.opener.document.forms[formname][target_fieldname];
var domnode_display = window.opener.document.forms[formname][target_fieldname+'_display'];
if(domnode_id) domnode_id.value = recordid;
if(domnode_display) domnode_display.value = value;
ret = true;
} else if(window.opener.document.EditView) {
var domnode_id = window.opener.document.EditView[target_fieldname];
var domnode_display = window.opener.document.EditView[target_fieldname+'_display'];
if(domnode_id) domnode_id.value = recordid;
if(domnode_display) domnode_display.value = value;
ret = true;
} else if(window.opener.document.DetailView) {
var domnode_id = window.opener.document.DetailView[target_fieldname];
var domnode_display = window.opener.document.DetailView[target_fieldname+'_display'];
if(domnode_id) domnode_id.value = recordid;
if(domnode_display) domnode_display.value = value;
ret = true;
} else if(window.opener.document.QcEditView) {
var domnode_id = window.opener.document.QcEditView[target_fieldname];
var domnode_display = window.opener.document.QcEditView[target_fieldname+'_display'];
if(domnode_id) domnode_id.value = recordid;
if(domnode_display) domnode_display.value = value;
ret = true;
}
var func = window.opener.gVTModule + 'setValueFromCapture';
if (typeof window.opener[func] == 'function') {
window.opener[func](recordid,value,target_fieldname);
ret = true;
}
console.log(ret);
return ret;
}