Table of Contents

DataSaved

This rule is triggered after saving.
This happens when :

  • the user clicks on the Save button
  • calling the SaveDataAsync method
Important

This rule is not executed when deleting an item of the main UI view of a screen as the DELETE API is immediately called without having to save.

Warning

When a child collection is embedded, the GET API returns a sub-collection embedded in its JSON response. The PUT and POST APIs called when saving expect the presence of this sub-collection in their payload.

Multiple APIs can have been called depending on the type of changes made:

  • POST when creating a new item
  • PUT when updating an existing item
  • DELETE when deleting an item in a collection that is not embedded

See this article for more information on event rules execution order.

Behavior in a master / detail view

In a master / detail UI, when both the main UI view and the detail UI view have a DataSaved event rule, the rule of the master element UI view is always executed. This is the case whether you only make changes on the detail items or not.
However, the rule of the details UI view is only executed when saving changes made to the detail items if the collection is not embedded.

Arguments

The Arguments property provides the following options.

Name Type Description
HasSucceeded bool Indicates whether the datasource has been successfully saved.
CreatedItems IReadOnlyCollection<T> where T is the UI view model Collection of the created items returned by the POST API which may have updated some of their properties on server-side (for example an auto-incremented integer property set as the key of the entity will have its real value here). Those items are also up to date in the datasource. Empty when HasSucceeded is false.
ModifiedItems IReadOnlyCollection<T> where T is the UI view model Collection of the updated items returned by the PUT API which may have updated some of their properties on server-side. Those items are also up to date in the datasource. Empty when HasSucceeded is false.

Item versus DatasourceCurrent

Since the rule is not tied to a specific item, the Item property does not exist in this rule, however, you can use Arguments.CreatedItems and Arguments.ModifiedItems to access the created and modified items.
DatasourceCurrent refers to the item at the current position in the datasource.

To know more on the difference between the Item and DatasourceCurrent properties in an UI view event rule, you can check this article.