DataSaving
This rule is triggered by a user or by code before calling the API to save the current datasource. This happens when :
- the user clicks on the
Savebutton - calling the
SaveDataAsyncmethod
Validation rules are triggered after this rule and can stop the save operation.
Note
In most cases, this rule should be set on server-side at the entity view level.
A good reason to set this rule on client-side rule is to avoid making an unnecessary API call.
Multiple APIs will be called depending on the type of changed made:
POSTwhen creating a new itemPUTwhen updating an existing itemDELETEwhen 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 DataSaving 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 |
|---|---|---|
Cancel |
bool |
If set to true, the API will not be called. |
Item versus DatasourceCurrent
Since the rule is not tied to a specific item, the Item property does not exist in this rule. However, you should properties CreatedItems and 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.