Tuesday, April 11, 2017

Change the "Source" redirection of SharePoint New and Edit forms on Save and Cancel

On document.ready put this code:-

    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 newPostbackUrl = oldPostbackUrl.replace(currentSourceValue, "https%3A%2F%2Fint%2Eapac%2Esp%2Ewp%2Ecorpintra%2Enet%2Fsites%2F04400%2FDashboard%2520UAT%2FSitePages%2FProjects%2Easpx");

        if (!PreSaveItem()) return false;
        WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(elementName, "", true, "", newPostbackUrl, false, true));

    });

No comments:

Post a Comment

Clearing Person/Group Values

To clear out or empty the values in person or group columns, how you do it depends on if the column is single-value or multi-value. For ...