Create Approve button within the editform

Home Forums Classic DFFS Create Approve button within the editform

Viewing 5 reply threads
  • Author
    Posts
    • #12108
      David M
      Participant

        Hello,

        I’m using Dynamic forms within my SPD workflow in SP 2010.

        For approvals, I currently have a radio button date field and also a comment field. Is it possible to have an approval button inside the form?

        There is a post of approval buttons in the header which I’ve read, but I’m trying to see if it is possible to put one inside the form.

        If there is a way to have an ‘Approval’ button, which then inserts the username and Time/date stamp into another field that would be ideal.

        Thanks so much,

        Dave

        p.s. I’ve included a version of what the screen looks like.

        Attachments:
      • #12157
        Alexander Bautz
        Keymaster

          Hi,
          If you want to insert the username and date by code and refresh the page (most likely in DispForm) you can add this code to the custom js textarea:

          function myCustomApproveFunction(){
              var data = {}, today = new Date(), res;
              data.PeoplePicker1 = _spPageContextInfo.userId;
              data.DateColumn1 = today.getFullYear()+"-"+(today.getMonth()+1)+"-"+today.getDate()+" 06:00:00";
              res = spjs.utility.updateItem({"listName":_spPageContextInfo.pageListId,"id":spjs.dffs.data.thisItemID,"data":data});
              if(res.success){
                  alert("Approved!");
                  location.href = location.href;
              }else{
                  alert(res.errorText);
              }
          }

          You must change “PeoplePicker1” and “DateColumn1” to your own field names.

          Then add this to a html section in one of your tabs:

          <input type="button" value="Approve item" onclick="myCustomApproveFunction();return false;">

          If you however wants to insert this information when doing a “hand editing” of the item in EditForm (to automate filling the PP and the date picker) you can use a rule and the “Set field value” option.

          Hope this helps,
          Alexander

        • #14617
          Rich Rockwell
          Participant

            Alexander, thanks for this.

            I’m not able to get it to work. I click the button and nothing happens. When I debug it, I get the message “Object doesn’t support property or method ‘updateItem'” Any suggestions?

          • #14681
            Alexander Bautz
            Keymaster

              Hi Rich,
              The method “updateItem” is part of the spjs-utility.js file. If you are using an older version of this file you can try changing “spjs.utility.updateItem” for “spjs_updateItem”.

              Alexander

            • #14699
              Rich Rockwell
              Participant

                That was it! That worked. Thank you, Alexander. You are the best!

              • #14703
                Alexander Bautz
                Keymaster

                  I’m glad it worked.

                  Happy new year!

                  Alexander

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