Adding "Save and Stay on Page" button in Edit form?

Forums Dynamic Forms for SharePoint Adding "Save and Stay on Page" button in Edit form?

Tagged: 

This topic contains 4 replies, has 2 voices, and was last updated by  Keith Hudson 4 years, 3 months ago.

  • Author
    Posts
  • #7231

    Keith Hudson
    Participant

    Is it possible to add a button in the edit form that will commit changes in the form to the SharePoint list, but post back to the edit form? I’ve tried putting in a header with

    <input type=”button” value="Submit” name="btnSave" onclick="javascript: {ddwrt:GenFireServerEvent(‘__commit’)}” />

    and several similar variations, but it seems that because the code is inside DFFS instead of on the native page, it doesn’t get transformed into the proper postback event on page rendering. Is there a quick and easy way to do this?

  • #7428

    Keith Hudson
    Participant

    I ran across this blog which gave me the headstart I needed: https://adrianhenke.wordpress.com/2010/08/19/custom-redirect-after-creating-a-new-sharepoint-item/

    The code I added to the JS Section of the Misc tab in the DFFS config of my Edit form is as follows:

    //this function renames the Save button to “Save and Stay on Page” and causes the save button to return to the same edit form it came from.

    $(document).ready(function() {
    var button = $(“input[id$=SaveItem]”);
    button.attr(“value”,”Save and Stay on Page”);
    // 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 newPostbackUrl = oldPostbackUrl + “&Source=” +oldPostbackUrl;
    if (!PreSaveItem()) return false;
    WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(elementName, “”, true, “”, newPostbackUrl, false, true));
    });
    }); //end ready function

  • #7429

    Keith Hudson
    Participant

    I discovered that the approach I just posted saves SOME fields and not others, so its back to the drawing board.

  • #7462

    Claudia Costa
    Participant

    Hi,
    I would really like this feature to be available ins the DFFS.
    Hope it will be implemented! Looking forward.
    Thanks
    Claudia Costa

  • #7477

    Keith Hudson
    Participant

    I succeeded in changing the onclick event of the Save button to save the record then post back to the edit form, BUT it seems that SharePoint 2013 handles multi-line text fields in some unusual way, because edits made to those fields did not get saved. Anyone attempting to add Save and Stay on Page functionality needs to test thoroughly that all fields are getting saved correctly before putting their solution into production.

You must be logged in to reply to this topic.

One thought on “Adding "Save and Stay on Page" button in Edit form?”

Comments are closed.