Feature Request: Go back to the originating view after editing a record

Forums Classic DFFS Feature Request: Go back to the originating view after editing a record

Viewing 6 reply threads
  • Author
    Posts
    • #35203
      Amal Vellappillil
      Participant

      Hi Alex,
      I have a feature request.

      Current Behavior:
      – Current view = View 1 (not the default view)
      – User clicks into a record from that view.
      – User clicks on edit to edit the record. Then saves the record.
      – User click on close button in display form.
      – User is taken back to list view. But this time user is taken to the default view instead of “View 1” (the originating view)

      Is it possible to have the user sent back to the originating view when the close button is clicked on “after editing a record from display form”?

      Thank you,
      Amal Vellappillil

    • #35209
      SteveE
      Participant

      I would suggest saving a step of the user having to click the close button and instead have it redirect after editing and clicking save.

      Alexander has mentioned how to do this in a few places, one here: https://spjsblog.com/forums/topic/redirect-based-on-form-values/

      In DispForm under the Misc tab, uncheck “Return to DispForm when editing and item and NOT opening the form in a dialog.”

      Then in EditForm under the Custom JS tab add this to the PreSaveAction:

      function dffs_PreSaveAction() {
      spjs.dffs.redirect(“/yourdefaultview.aspx”,false);
      return true;
      }

    • #35219
      Alexander Bautz
      Keymaster

      By default SharePoint redirects you back to wherever the “Source” parameter in the URL query string points to.

      If you open a DispForm and then navigates to EditForm the default redirect would be back to the view you came from – are you using any custom js or misc tab settings to change the redirect?

      Alexander

    • #35222
      Amal Vellappillil
      Participant

      I have the “Return to DispForm when editing an item and NOT opening the form in a dialog” checked under “Misc” tab. Is there a way to bulk update all list configurations in a site to have this option unchecked?

    • #35232
      Alexander Bautz
      Keymaster

      There is no easy way to bulk edit items, but it can be done with a custom script that loops through all stored configurations.

      How many configs do you need to change?

      Alexander

    • #35277
      Amal Vellappillil
      Participant

      Around 50 configs spanning across 8 subsites in 1 site collection.

      • #35287
        SteveE
        Participant

        Sorry to say, but it’s probably more hassle to set up something to do it in one action than to go through them individually.

        If you go to the installer page and click the Review installations tab, you’ll see all of your configurations. You only need to update the DispForm and you can access them all from this page.

        You could do them all at once and it would probably take an hour. Or you could do the main ones first and then do the rest when you have time or update the form.

    • #35297
      Alexander Bautz
      Keymaster

      Hi,
      You can use a script like this example. You must run it in the console of one of your forms in each subsite as it uses some code from DFFS.

      Code example:

      var allConfig = spjs.utility.queryItems({
          "listName": "SPJS-DynamicFormsForSharePoint",
          "query": "<Where><IsNotNull><FieldRef Name='Title' /></IsNotNull></Where>",
          "viewFields": ["ID", "Title", "blob"]
      });
      jQuery.each(allConfig.items, function (i, item) {
          if (item.Title.charAt(0) === "/" && item.blob !== null && item.blob.charAt(0) === "{") {
              var config = JSON.parse(item.blob);
              // Use console.log to view the config in the console to locate the parameters you want to change
              // console.log(config);
              // This example changes redirEditToDisp to false
              if (config.redir.redirEditToDisp) {
                  config.redir.redirEditToDisp = false;
                  // Backup current config
                  var backupRes = spjs.utility.addItem({
                      "listName": "SPJS-DynamicFormsForSharePoint",
                      "data": { "Title": "[backup]" + item.Title, "blob": item.blob }
                  });
                  if (backupRes.success) {
                      // Apply changes if config was backed up successfully
                      var updateRes = spjs.utility.updateItem({
                          "listName": "SPJS-DynamicFormsForSharePoint",
                          "id": item.ID,
                          "data": { "blob": JSON.stringify(config) }
                      });
                      if (updateRes.success) {
                          console.log("Made backup and updated config for " + item.Title);
                      }
                  } else {
                      console.log("*** Failed to backup config for " + item.Title + ": " + backupRes.errorText + ". No changes were made to the config.");
                  }
              }
          }
      });

      This script will loop trough ALL configs in the current site and make changes. It will make a backup of the original config in case you need to roll back. If so, open the “Export, import and restore” tab and hit “Browse restore points and deleted configurations”.

      Please read the comments in the code and make changes to match the changes you want to make.

      Alexander

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