Working in SharePoint 2013, I have Parent Child lists: Request is the Parent, and Task is the Child. I have used the SharePoint Hillbilly Tabbed form for the Parent, and a web part showing the related Tasks via Connections. So far, so good. I added code in a separate web part, to open a Child New Item, and post the related ParentID:

<script type="text/javascript">
function NewChildItem(newFormPath) {
 // Get the Query String values and split them out into the vals array
 var vals = new Object();
 var qs = location.search.substring(1, location.search.length);
 var args = qs.split("&");
for (var i=0; i < args.length; i++) {
 var nameVal = args[i].split("=");
var temp = unescape(nameVal[1]).split('+');
nameVal[1] = temp.join(' ');
vals[nameVal[0]] = nameVal[1];
 var IDColumn = vals["ID"];
NewItem2(event, newFormPath + "?ParentID=" + IDColumn);
<a href="javascript:NewChildItem(&#39;/sites/programs/ebos/Lists/Task/NewFormCustom.aspx?&#39;);"> Click here to add a new Task to this Request</a>

However, once the New Form has been saved, the user finds the Parent item closed, and they have been returned to the original View. The ideal would be to open the NewFormCustom for the Child in a Dialog Box, populated with the related ParentID, and when the Child Item is saved and closed, the user will still see the Parent Request item. (If the new Child Item were to display in the list, that would be nice, but not required at this point…)

I downloaded the SP15ModalDialog.js, stored it in my jQuery library, and call it in my hillbillyForm.js

<script src="../../SiteAssets/jQuery/SP15ModalDialog.js"></script>

I have successfully opened the NewFormCustom in a Dialog Box, using this code:

<a href="#" onclick="openInDialog(500,600,true,true,true,'/sites/programs/ebos/Lists/Task/NewFormCustom.aspx?RootFolder=&IsDlg=1');">New Task</a>

I have not been able to open the NewFormCustom, and pass the ParentID. Here is my latest best attempt:

<a href="javascript:NewChildItem(&#39;openInDialog(500,600,true,true,true,&#39;/sites/programs/ebos/Lists/Task/NewFormCustom.aspx?IsDlg=1&#39;)&#39;);"> Click here to add a new Task to this Request</a>

Thank you in advance for your help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.