Save and add new child directly

Forums vLooup for SharePoint Save and add new child directly

This topic contains 0 replies, has 1 voice, and was last updated by  Alexander Bautz 5 years ago.

  • Author
    Posts
  • #6514

    Alexander Bautz
    Keymaster

    I got a question from William like this:

    So this is working great. Because the SPID is not created until the record of the parent is saved, I assume I cannot create child records when making a new parent item. So I have this case where I need to enter multiple child items related to a parent, is there a way to have something that would basically be a button or something that would “Save and add new child item” vs hitting the save button, finding the parent record in a long list and clicking create new child each time? Basically, what is the easiest way to create multiple child records?

    Thanks

    This can be done by adding this snippet of code to the child NewForm:

    <script type="text/javascript">
    if(location.search.indexOf("SendMeBackToNewForm") === -1){
    	var nURL = location.href.split("&Source=")[0];
    	nURL += "&Source="+nURL.split("&").join("%26")+"%26SendMeBackToNewForm";
    	location.href = nURL;
    }else if(location.search.indexOf("Source=") === -1){
    	location.href = location.href+"&Source="+location.href.split("&").join("%26");
    }
    
    if(GetUrlKeyValue("ClickCancelBTN") === "1"){
    	$("input[id$='diidIOGoBack']:last").trigger("click");
    }else{
    	$("input[id$='diidIOGoBack']").click(function(){
    		location.href = location.pathname+"?ClickCancelBTN=1";
    	});
    }
    </script>

    Please note that this code requires jQuery to be loaded in the page. This should already be in place when you add the vLookup solution to the NewForm, but you must place this snippet below the jQuery script, but before the vLookup script is loaded.

    Alexander

You must be logged in to reply to this topic.