How to get ID of saved item in DFFS form?

Forums General discussion How to get ID of saved item in DFFS form?

Tagged: 

Viewing 4 reply threads
  • Author
    Posts
    • #34946
      Harsh
      Participant

      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?

    • #34954
      Alexander Bautz
      Keymaster

      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 2 years, 5 months ago by Alexander Bautz. Reason: Added note about _DFFSID
    • #34972
      Harsh
      Participant

      It helps!
      Thanks @alexander

    • #34976
      Harsh
      Participant

      How can i close DFFS form just like Edit form close after save?

    • #34980
      Alexander Bautz
      Keymaster

      You can use this snippet to trigger a click on the cancel button:

      jQuery("input[id$='_diidIOGoBack']:first").trigger("click");

      Alexander

Viewing 4 reply threads
  • You must be logged in to reply to this topic.