SharePoint New Item Form Actions

The following post describes 3 of the many new Form Actions available in SharePoint.

Cancel:
This example shows how to return to home page after user cancels creating the item.

$(document).ready(function() {
    $('input[value=Cancel]').click(function() {
        window.location.replace("https://<siteurl>/sites/Site/SitePages/Home.aspx");
    });
});

Pre-Save:
This example shows how to show an alert and wait for OK or Cancel action.

function PreSaveAction() {
    if (confirm("Proceed with saving the item?"))
        return true;
    else
        return false;
}

Post-Save:
This example shows how to return to home page after user creates the item.

function PostSaveAction() {
    window.location.replace = "https:///sites/Site/SitePages/Home.aspx";
    return true;
}

Do make a note that above code requires the Jquery is referenced in the page.


Leave a Reply

Your email address will not be published / Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.