in online sharepoint PreSaveItem() called but not saving data

Forums General discussion in online sharepoint PreSaveItem() called but not saving data

Viewing 2 reply threads
  • Author
    • #24615
      Linda Kamos

      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:

      $(function () {

      var button = $(“input[id$=SaveItem]”);
      // change redirection behavior
      button.removeAttr(“onclick”); {
      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!

    • #24638
      Alexander Bautz

      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:


      If you do use DFFS you can use code like this:

      function dffs_PreSaveAction(){
        spjs.dffs.redirect("Path to redirect to",false);
        return true;


    • #24645
      Linda Kamos

      Thank you! I forgot to mention, I didn’t know what DFF means, and I was not using it. Thanks anyway.

Viewing 2 reply threads
  • You must be logged in to reply to this topic.