Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    DynamicForm.saveData

    I've just wrestled with DynamicForm.saveData(). I had presumed that saveData was smart and knew when to add and when to update a record. I presume it's supposed to work that way?

    I don't have time to create a small repro case right now, but I solved my problem by calling form.getValuesAsRecord() and adding/updating the record in my datasource. When I did not do this, my second call to saveData (after making a field change the form) added a duplicate record instead of updating the record.

    #2
    Look at DynamicForm.setSaveOperationType for details on how the form "knows" when to add/update. You can override that as needed but if the data returned from the add includes the primaryKey (you must have one) the form will switch automatically.

    Comment


      #3
      Thank you David.

      I still did not figure out why it was not working, but I came up with a solution. The initial user action to add a record had a prompt in it, which depending on the answer, would then cause an update on the same record. I have fixed the problem by changing the workflow so there is a single add operation and the optional update is now a condition in the form.

      I thought this might have been caused by batching, but checking the RPC logs it does not appear to be it was queued. Anyway, the workflow refactor is better and the problem is gone.

      Comment

      Working...
      X