DFFS javascript does not save record

Forums Dynamic Forms for SharePoint DFFS javascript does not save record


This topic contains 2 replies, has 2 voices, and was last updated by  David M 2 months, 1 week ago.

  • Author
  • #25943

    David M

    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});
    location.href = location.href;

  • #25952

    Alexander Bautz

    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.


  • #25964

    David M

    thanks for the feedback Alexander.

You must be logged in to reply to this topic.