I've set up a list with a Parent Child relationship. When the Parent is edited and save button pressed ther modal dialog opens the child list. When the child is saved the parent is saved also. The problem is I need a way to pass the ID of the parent item to the child to maintain the relationship. I have set up a lookup for the parent id in the child, however i dont think this is necessary as the ID parameter of the Parent item can be passed to the child. The code below does everything except maintain the relationship, could someon assist pls?
var setTrue = false; var target; var contName; function PreSaveItem() { //on first load global varible setTrue is false so we can load the popup. //but when true it will save parent list imitating save click event. if ("function"==typeof(PreSaveAction)&& setTrue == false) { //get the clicked save button so that we can use the id (name) later to save when doing a postback. target = event.target || event.srcElement; contName = target.name; //call the save action to load the child list PreSaveAction(); } else { //do postback with parent save button manually WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(contName, "", true, "", "", false, true)); } } //function that creates child popup to add new item to a child list function PreSaveAction() { var dialogOptions = SP.UI.$create_DialogOptions(); dialogOptions.url = 'http://sharesite/sites/mysite1/Lists/Time3/NewForm.aspx'; dialogOptions.width = 750; dialogOptions.height = 500; dialogOptions.dialogReturnValueCallback = Function.createDelegate( null, CloseCallback); SP.UI.ModalDialog.showModalDialog(dialogOptions); } //actions (save/cancel) for the child form function CloseCallback(strReturnValue, target) { if (strReturnValue === SP.UI.DialogResult.OK) { //if we save than set global bool to true setTrue = true; alert("Thank you for adding time value"); //call presave item for parent list save PreSaveItem(); } if (strReturnValue === SP.UI.DialogResult.cancel) { setTrue = false; alert( "You clicked cancel!"); } }