Home › Forums › General discussion › How to get ID of saved item in DFFS form?
Tagged: #DFFSform
- This topic has 4 replies, 2 voices, and was last updated 4 years, 2 months ago by
Alexander Bautz.
-
AuthorPosts
-
-
October 28, 2021 at 16:31 #34946
I come across scenario where i need to get ID to saved item from new list when spjs.dffs.triggerSave() event fire.
I need item id so i can call some rest api calls in to lists, how can it possible to call function after form save with item ID?
-
October 28, 2021 at 18:16 #34954
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 4 years, 2 months ago by
Alexander Bautz. Reason: Added note about _DFFSID
-
This reply was modified 4 years, 2 months ago by
-
October 29, 2021 at 15:29 #34972
It helps!
Thanks @alexander -
October 29, 2021 at 15:50 #34976
How can i close DFFS form just like Edit form close after save?
-
October 30, 2021 at 08:35 #34980
You can use this snippet to trigger a click on the cancel button:
jQuery("input[id$='_diidIOGoBack']:first").trigger("click");Alexander
-
-
AuthorPosts
- You must be logged in to reply to this topic.