LSPS documentation logo
LSPS Documentation
Creating a Model Instance from Document and Navigating to its To-Do on Submit

To create a model instance from a document and then navigate to one of its To-dos, do the following:

  1. Open the form of your document:
    • For ui-module forms, define a listener that will create the model instance as follows:
      1. Attach a listener of the required type to a component.
      2. Create the model instance in its persist action, for example, createModelInstance(true, getModel("myModelName"), null)
      3. Define a listener with the Submit action (it represents the moment when you want to submit the data and navigate away from the document).
        createMIFromPersistAction.png
    • For forms-module forms, define the following expression on the respective component listener (typically the click listener of an action component, such as a Button):
      { e -> createModelInstance(true, getModel("runMe"), null); Forms.submit()}
      createMIFromDocForms.png
  2. Optionally, define the Navigate property in the document definition so the document navigates to a to-do generated by the model instance when submitted:
    \navigates to the first to-do generated by the document:
    {todos:Set<Todo> -> new TodoNavigation(todo -> todos[0], openAsReadOnly -> false)}