DFFS javascript does not save record

Forums Dynamic Forms for SharePoint DFFS javascript does not save record

Tagged: 

Viewing 2 reply threads
  • Author
    Posts
    • #25943
      David M
      Participant

      Hello,
      First, DFFS is great.

      Looking for some help on adding a save function to this script below.

      Currently I have a button in a DFFS form that calls a javascript which inserts the userID and the date into some R/O fields in the form. It works great. The issue is if a user edits any field in the form before they click the approve button, the changes are not saved. I tried adding presave and save however it didn’t work.

      appreciate any help.

      here is the script:

      function myAIApproveFunction(){
      var data = {}, today = new Date(), res;
      data.ApprovalName = _spPageContextInfo.userId;
      data.ApprovalDate = today.getFullYear()+”-“+(today.getMonth()+1)+”-“+today.getDate()+” 06:00:00″;
      res = spjs_updateItem({“listName”:_spPageContextInfo.pageListId,”id”:spjs.dffs.data.thisItemID,”data”:data});
      if(res.success){
      location.href = location.href;
      }else{
      alert(res.errorText);
      }
      }

      Attachments:
    • #25952
      Alexander Bautz
      Keymaster

      Hi,
      You cannot use code to write to the same item as you edit – it will cause a version conflict when you hit the normal save button.

      If you need to use EditForm and let the user edit any field before hitting the Approve button, I recommend writing the values from the Approve button click to the fields in the form, and then trigger a normal save of the form with spjs.dffs.triggerSave(); – not using the spjs_updateItem function.

      If you don’t really need to let the user edit anything, my recommendation would be to have this button in DispForm and not in the EditForm – this way you avoid the problem.

      Alexander

    • #25964
      David M
      Participant

      thanks for the feedback Alexander.

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