Tuesday, October 13, 2015

Redirect from NewForm to EditForm in DFFS

Here is an alternative solution for redirecting from NewForm to EditForm when using DFFS.

This solution is based on entering NewForm, filling in the Title field, and hitting “Save” to continue in EditForm.

Here is an example on a NewForm

SaveAndContinue

Add this code to the Custom JS

function saveAndRedir(){
var ok = spjs.dffs.check_Mandatory(["Title"]), data = {}, newItem;
if(ok){
data.Title = getFieldValue("Title");
newItem = spjs.utility.addItem({"listName":_spPageContextInfo.pageListId,"data":data});
if(newItem.success){
location.href = location.pathname.substring(0,location.pathname.lastIndexOf("/")) + "/EditForm.aspx?ID="+newItem.id;
}else{
alert(newItem.errorText);
}
}
}

function PreSaveAction(){
saveAndRedir();
}

This is it – test it and let me know how it works out  in the Forum.

Best regards,
Alexander


by Alexander Bautz via SharePoint JavaScripts

No comments:

Post a Comment