Note: Nintex Apps data centers are located in West US and Australia (AUS). In-region processing of Nintex Apps data is only available in these regions.
Use a Modal to Create New Records
Often a table that lists records only displays a few select fields needed to distinguish records from one another. Adding a new record directly to the Table allows end users to create a new record by filling in the fields on the table. But what if you want to capture more data than just that in the displayed fields?
Use a modal! A modal allows users to create a fully-featured record.
Assumptions
Note: This tutorial assumes that you have a Nintex Apps page with a functioning model that lists records on a Table component. For best results, select a useful field (like CreatedDate) in Fields to order records by on the model, and set that field to display in DESC order. (This way, when end users create a new record, it will be added to the top of the table.)
If you prefer to sort by alphabetical order, set Fields to order records by to an alphabetical label (for example, Name) and display it in ASC order.
You have that model on a connection that's being used to display the table of records. But now you want to add records to that model's data. To do this via the modal, create a new model on the same connection. This model will serve as a "container" for the new record, which will then be added to the original object.
The quickest way to do this is by cloning the existing model under a new name, then perform the following edits to the new model's properties:
- Uncheck Query on page load.
- Make sure the Max number of records field is blank.
- Uncheck Create default row if model has none.
- Add any additional fields you want to display in the modal. (Remember, being able to fully populate a new records is the point of using the modal rather than inline record creation. Be sure the model has fields for the data you want to capture.)
- Remove any conditions you had on the original model.
End users need a way to open the modal and start adding information about the new record. In this tutorial, we'll use a button.
- Drag and drop a Button Set component above the table.
- Model: Select the cloned model.
- Click the button and in the General tab in the properties pane, make the following edits:
- Button label: Create New Record
- Button icon: If desired, add an icon by clicking on the icon selector.
Now, use the Action Framework to configure the button with multiple actions that will open the modal and allow the end user to add data.
- In the Actions tab in the properties pane, click
- First action: Ensures that the model associated with the modal starts empty each time a end user clicks the trigger action.
- Action type: Remove all rows from model
- Models to Empty: The name of the cloned model (not the original model).
- Second action: After the end user adds a new record using the modal, Nintex Apps requerys the table model. If there is any unsaved data in the table, that data would be deleted. This action protects that unsaved data from being lost.
- Action type: Save model changes
- Models to Save: The name of the original model.
- Third action: Creates a new row on the cloned model (for the new record)
- Action type: Create New Row(s)
- Model: The name of the cloned model.
- Place row at ...: Start of Model data.
- Have associated Components initially show this row in ...: Edit Mode.
- Rows to use: Rows in context
- Fourth action: Opens the modal and allows the user to enter record information.
- Action type: Show modal
Add action to create the following actions: - First action: Ensures that the model associated with the modal starts empty each time a end user clicks the trigger action.
Now you have a button that safeguards any unsaved data from the table, ensures that the cloned "holding" model is empty of data, and opens a modal.
It's time to build the actual modal:
-
In the Fourth Action (see previous section), click Configure modal.
-
Drag and drop a Form component into the modal and edit the following properties:
- In the General tab.
- Model: Select the cloned model.
- Default mode: Edit.
- Show save and cancel buttons: Uncheck.
Note: In the next section, we'll create two buttons that handle saving and canceling—along with a few additional actions.
- In the General tab.
-
In the Form component, set up the entry form with appropriate sections and fields.
First, add a container for the buttons:
-
Drag and drop a Button Set into the modal above the Form and edit the following properties:
- Model: Select the cloned model.
-
In the Button Set, click
Add Button so that there are two buttons.Note:If this feature needs a Save and a Cancel button, why did we remove the Save/Cancel buttons that were already part of the Form component? (Good question!)
That set of buttons on the component can only do one thing: save edits or cancel those edits. However, we need buttons that can do several things, so we'll create them to run multiple actions.
The Save button needs to perform multiple actions: save the new data; query the original model (to refresh the underlying table and display the new record); close the modal.
-
Click the first button and edit the following properties in the General tab:
- Button label: Save.
- Button icon ( optional ): Select an icon for this button.
-
Click the Actions tab, and configure the following actions on the button:
- First action: Lets the user know that the data in the modal is being saved.
- Action type: Show message and block UI.
- Message: Saving
- Timeout: Never
- Second action: Saves the new record information to the cloned model.
- Action type: Save model changes.
- Models to Save: Select the cloned model.
- Click Nintex Apps will unblock the UI so that the end user can fix the problems in the form and try again. Configure:
- Action type: Unblock the UI
Add on-error action: If there are problems saving—such as required fields that are missing—
- Third action: After the model data has been saved to the cloned model, Skud must query the original model so the new data appears there as well. ( Remember, they are built from the same connection. ) This action queries the original model, which means the new record will display in the updated Table, which is connected to the original model.
- Action type: Query model
- Model: Select the original model.
- Query behavior: Standard - Completely Replace Data
Note: If the new record does not appear to display in the list, check out how you ordered the list (See Assumptions, above.)
- First action: Lets the user know that the data in the modal is being saved.
- Fourth action: Closes the modal so that the user can see the list again.
- Action type: Close all modals
- Fifth action: Unblocks the UI so the user can continue to interact with the Nintex Apps page.
- Action type: Unblock the UI
If the end user changes their mind, they need to cancel out of the modal, but like the Save button, the Cancel button needs to do more than one thing:
-
Click the second button and edit the following properties in the General tab:
- Button label: Cancel.
- Button icon ( optional ): Select an icon for this button.
-
Click the Actions tab, and configure the following actions on the button:
- First action: Removed all data entered in the modal before it is saved and cancel all changes to the model.
- Action type: Cancel model changes.
- Models to Cancel: Select the cloned model.
- Second action: Closes the modal so that the user can see the list again.
- Action type: Close all modals.
Note:What if the user clicks the X on the modal instead of Cancel? They won't remove the data entered into the Form in the modal via the**Cancel model changes** action. However, we've got that covered.
Remember that the first action added to the Create New Record button removes any existing data from the new record model; that action ensures that if the user skips the Cancel button (and therefore, the Cancel model changes action), any residual data left in the modal will be cleared out before the modal is opened again for new record creation.
- First action: Removed all data entered in the modal before it is saved and cancel all changes to the model.
-
Close the modal and click Save.
The End User's Experience
The user clicks Create New Record. Nintex Apps displays the modal, where the user can add record data. Once saved, the list table refreshes and the new record displays.