Announcement

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

  • BUG report: valuesManager.saveData() fails when members undefined

    In our application we are calling valuesManager.saveData() and getting a failure when members is undefined. We can work-around this by testing valuesManager.getMembers() before calling saveData() but it is a bug that you might want to fix, ie calling valuesManager.saveData() can do nothing if there aren't any members associated with the valuesManager yet.
    We are not sure why the valuesManager has no members but dynamicForm instances are usually associated some time after valuesManager.create(), so it's quite likely that this can happen. In our case some of the associated dynamicForm instance create calls are conditional on other settings.

    we are running Version v12.0p_2018-08-22/LGPL Deployment (2018-08-22)
    In the (debug, not-minified) ISC_Forms.js file, the fail is happening within function valuesManager._saveDataReply() (line 74,860)
    The failure is happening for us when referring to the variable members in the loop:
    for (var i = 0; i < members.length; i++) { (line 75,010)

    I suggest that you test for "no members assigned" at the top of the _saveDataReply() function after the line
    var members = this.getMembers();
    since I think there is nothing to do in the function if there are no members to save yet?
    Thanks

  • #2
    Please simply avoid a call to saveData() on a ValuesManager with no members. That can't possibly achieve anything, so if it did not generate a crash, it would generate a warning, and you'd need to avoid it regardless.

    Comment


    • #3
      Thanks for the feedback. As a work-around, we are able to test for members before going ahead with saveData().
      However, there is a legitimate use-case for ValuesMananger without any (DynamicForm) members needing to save.
      We have an application where several different DynamicForm editors are made members of a ValuesManager and the form is shown in a modal Dialog window. The Dialog, and form, is destroyed on close. Later, the user chooses to save the VuluesManager data to the back-end database some time after Dialog forms have gone away.
      ValuesManager works quite well in this scenario, and I think it is in the spirit of what a ValuesManager is for, though our usage is a little unusual.
      It's a suggestion for enhanced functionality, I guess. If you want to work on this, we would probably be able to supply test code.
      Thanks

      Comment


      • #4
        Retrieve the values from the ValuesManager and call DataSource.addData() or DataSource.updateData() in this case.

        The only purpose of the ValuesManager is to manage values across multiple forms. With no forms it has no purpose, and it is in fact senseless to try to save it because it would have nothing it could do with the validation errors that might result.

        This may also mean that your current flow, which destroys all user input forms before saving, is broken because it would not handle any server-side validation errors (and even if there are no such cases now, you may add some in the future).

        Comment

        Working...
        X