How to redirect to a Custom Page after adding a sharepoint list item in SharePoint 2013?

In SharePoint 2013, if you want to redirect to a specific custom page or Thank you Page after creating a list item or editing a list item. You need to add the below Jquery code in the NewForm.aspx or Editform.aspx.

 

$(document).ready(function() {

var button = $(“input[id$=SaveItem]”);
// change redirection behavior
button.removeAttr(“onclick”);
button.click(function() {
var elementName = $(this).attr(“name”);
var aspForm = document.forms[‘aspnetForm’];
var oldUrl = aspForm.action;
var SourceValue = GetUrlKeyValue(“Source”, true, oldUrl );
var newUrl = oldUrl .replace(SourceValue , “Mycustompage.aspx”);

if (!PreSaveItem()) return false;
WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(elementName, “”, true, “”, newUrl , false, true));
});

});

Happy SharePointing Folks. Hope it helps you!!

Leave a Reply

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