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
    Posts
    • #24615
      Linda Kamos
      Participant

      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:
    • #24638
      Alexander Bautz
      Keymaster

      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

    • #24645
      Linda Kamos
      Participant

      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.