Home › Forums › General discussion › in online sharepoint PreSaveItem() called but not saving data
Tagged: Javascript, online sharepoint, redirect, save button
- This topic has 2 replies, 2 voices, and was last updated 5 years, 8 months ago by Linda Kamos.
-
AuthorPosts
-
-
April 2, 2019 at 23:10 #24615
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!
Attachments:
-
April 3, 2019 at 15:26 #24638
I’m unfortunately not able to help you with this snippet if you don’t use DFFS, but if you control the URL the user clicks to open the NewForm you can add a query string key like this to redirect:
.../Lists/YourList/NewForm.aspx?Source=/Path/to/redirect_page.aspx
If you do use DFFS you can use code like this:
function dffs_PreSaveAction(){ spjs.dffs.redirect("Path to redirect to",false); return true; }
Alexander
-
April 3, 2019 at 16:44 #24645
Thank you! I forgot to mention, I didn’t know what DFF means, and I was not using it. Thanks anyway.
-
-
AuthorPosts
- You must be logged in to reply to this topic.