Save for later Button

Home Forums General discussion Save for later Button

Viewing 11 reply threads
  • Author
    Posts
    • #24720
      Maciek Grischke
      Participant

        Is there a way to add a button that will say “Save for later”, button that will change a Boolean value to Yes and then save the item/form.

        Say I have a boolean column called: “Save for later”. I will program my Flow to ignore this task if this column has a value “Yes”.

        Can I add a button, rather than a field/option, that will change the value to Yes in the background, and then saves the form?

        When the item is edited and the creator clicks on Submit (or save) button, the value would change to “No”.

      • #24726
        Alexander Bautz
        Keymaster

          Add this to your Custom JS:

          // When loading the form it should set the boolean column to false
          setFieldValue("SaveForLaterBoolean",false);
          
          // Insert button
          jQuery("input[id$='_diidIOSaveItem']").before("<input type='button' class='ms-ButtonHeightWidth' style='margin-right:4px;' value='Save for later' onclick='saveForLater()' />");
          
          function saveForLater(){
          	setFieldValue("SaveForLaterBoolean",true);
          	spjs.dffs.triggerSave();
          }

          Change “SaveForLaterBoolean” to match your boolean field internal name.

          Let me know how it works out.

          Alexander

          • This reply was modified 5 years, 8 months ago by Alexander Bautz. Reason: Added spjs.dffs.triggerSave();
        • #24729
          Maciek Grischke
          Participant

            Thanks Alexander,

            works beautifully 🙂

            I knew I could count on you.

            Many thanks, as always!

          • #24736
            Maciek Grischke
            Participant

              Alexander, is it possible to have “Save for later” button in DisplayForm?

            • #24742
              Alexander Bautz
              Keymaster

                I’m not sure how you would use it in DispForm – there is not saving going on there – please explain.

                Alexander

              • #25056
                Maciek Grischke
                Participant

                  Hi Alexander,

                  I think what I meant was to be able to re-open the previously closed ticket.

                  I asked another question in a separate thread, but it’s for EditForm – I asked about hiding buttons based on fields values.

                  I think once the ticket is closed, I will want to hide Edit Button or change it to Re-open ticket and set the Status value to Open, and to re-open the ticket, the user will only be able to do this from DispForm. Is it possible to do from DispForm?

                • #25086
                  Alexander Bautz
                  Keymaster

                    Hi,
                    Yes, you can add a button that calls a function like this:

                    function reopenTicket() {
                        var res = spjs.utility.updateItem({
                            "listName": _spPageContextInfo.pageListId,
                            "id": spjs.dffs.data.thisItemID,
                            "data": {
                                "Status": "Open"
                            }
                        });
                        if (res.success) {
                            // Status set successfully
                        } else {
                            alert(res.errorText);
                        }
                    }

                    Change “Status” to match your field name and “Open” to the value you like to set.

                    Alexander

                  • #25104
                    Maciek Grischke
                    Participant

                      Thanks,
                      The only problem I have is that I can’t figure out what is the ID of Edit Button.

                      I tried this (and few other IDs):

                      // Insert button
                      jQuery("input[id$='_editItem']").before("<input type='button' id='_editItemBtn' class='ms-ButtonHeightWidth' style='margin-right:4px;' value='Re-open this ticket' onclick='saveForLater()' />");
                      

                      but no luck 🙁

                    • #25135
                      Alexander Bautz
                      Keymaster

                        You must use the developer tools: right click the button and select “inspect” and you will find the id is dffs_editItemBtn.

                        The only thing you must do is to set a 1100ms timeout because this edit button is inserted by DFFS after a 1000ms timeout – the extra 100ms ensures your snippet will find it:

                        setTimeout(function(){
                            jQuery("#dffs_editItemBtn").before("<input type='button' id='_editItemBtn' class='ms-ButtonHeightWidth' style='margin-right:4px;' value='Re-open this ticket' onclick='saveForLater()' />");
                        },1100);

                        Alexander

                      • #25139
                        Maciek Grischke
                        Participant

                          Brilliant, this worked. I did try with dffs_editItemBtn, but I was missing the delay function. Thanks again as usual!

                        • #32696
                          Maciek Grischke
                          Participant

                            Hi Alexander,

                            is there a way to move the additional button (Save for Later) up within the form?

                          • #32699
                            Alexander Bautz
                            Keymaster

                              You can move an item like this:

                              jQuery("#Id_of_element_to_move").appendTo(jQuery("#id_of_element_to_move_into"));

                              Alexander

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