Hi,
spjs.dffs.triggerSave() only triggers the built in save function in SharePoint (by clicking the save button) and won’t return anything so if this is in NewForm you cannot actually get the id unless you save the NewForm entirely programmatically.
You can do it instead by redirecting to DispForm after saving as shown below.
Add this to your NewForm Custom JS:
function dffs_PreSaveAction() {
spjs.dffs.redirect(location.pathname.substring(0, location.pathname.lastIndexOf("/")) + "/DispForm.aspx?DFFSID=" + spjs.dffs.data._DFFSID + "&RedirFromNewForm=1", false);
return true;
}
Now add this to your DispForm Custom JS:
if(GetUrlKeyValue("RedirFromNewForm") === "1"){
// From NewForm - do your magic here
var itemId = spjs.dffs.data.thisItemID;
alert("Item id: " + itemId);
}
Please note that for this to work you must add a single line of text field to your form with the internal name “_DFFSID”.
Alexander
-
This reply was modified 3 years, 2 months ago by Alexander Bautz. Reason: Added note about _DFFSID