We are using online sharepoint 2013/2016. I need to redirect to a specific page after clicking save button in newform.aspx. My redirected page has a specific DispID from query string. I used code below:
https://code.jquery.com/jquery-3.1.0.min.js
$(function () {
var button = $(“input[id$=SaveItem]”);
// change redirection behavior
button.removeAttr(“onclick”);
button.click(function() {
var elementName = $(this).attr(“name”);
var aspForm = $(“form[id=’aspnetForm’]”);
var oldPostbackUrl = aspForm.get(0).action;
var currentSourceValue = GetUrlKeyValue(“Source”, true, oldPostbackUrl);
var issueID = getCookie(“myID”);
var redirectPage=”/Lists/PM2/DispForm.aspx?ID=”+ myID;
var newPostbackUrl = oldPostbackUrl.replace(currentSourceValue, redirectPage);
if (!PreSaveItem()) return false;
WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(elementName, “”, true, “”, newPostbackUrl, false, true));
});
});
While the redirect part is working perfect for above code(successfully go to “DispForm.aspx?ID=1”), I found the new list item was not saved at all. Any suggestions what I can do to make sure the PreSaveItem() working also? Thank you!