Error saving to variable in load

I have a variable in a SAIL form that needs to be updated whenever a row is selected in a grid (call this local!dataSelected_name).  This then needs to be passed into another SAIL form where the user can alter the value and save it.

The issue I have is that an error is thrown saying the variable must be a load variable, but it needs to be updated when a user takes an action on the form (so I created it as a with variable).

Any ideas?

  Discussion posts and replies are publicly visible

  • 0
    Certified Lead Developer
    If you're going to be having users or on-form actions do manual updates to the value of a local variable, the variable should in fact be declared as a load() variable. It of course requires a somewhat different design approach to with() variables which are updated 'live', but strictly automatically and in accordance with the initial definition.

    In your case, if you need the variable to be updated whenever (for example) the user interacts with a grid, then you will want to use a!save() in the saveInto section of the grid to set whatever value is necessary. Likewise with any other fields on the form that would cause its value to update when interacted with.
  • So the action in the grid that updates the variable is actually a row selection of the grid using the left hand checkboxes. This is why I'm doing the with of the variable which captures that user interaction with the form.
  • The things to understand is that if a user needs to update a variable that variable has to be a load variable which ensures that the values saved is not changed by reinitialise due to reevaluation of a form which happens in case of with variables. So if we want to use a variable in saveInto these variables should be defined in load (we use saveInto to make sure we set variable to a value implicitly). In your case you will have to change the way you initialise the values and use saveInto in grid to explicitly set the values
  • 0
    Certified Lead Developer
    in reply to Jacob Edelman
    I understand, but like I said, you'll need to refactor a bit, so as to do the update of your local variable manually within the saveInto of your grid in order to get the other functionality you've described working.