How To: Use Expressions on an Editable List View
When using Expressions on an Editable List View, it is important to know the impact it will have in runtime. Following is an example of how Expressions can be applied and the behavior thereof in runtime.
The first method is to apply an Expression on the body control and apply aggregation on the related field. In this instance, the related field will be updated per row once the Expression is evaluated. Aggregations, for example, are calculated according to the latest field information on the View and NOT necessarily the information as saved in the SmartObject.
We've created a SmartObject and captured data in the SmartObject. The values in the SmartObject prior to applying an Expression on the body control are as follows:
We then created an Editable List View and selected the Sale Amount column on the Layout screen. Next we added an Expression on the body control (1) to multiply the Sale Quantity by 2, and then added a control that aggregates the sum of the Sale Amount column (2).
When running this View, the values reflected are according to the Expressions applied and NOT according to what is currently reflected in the SmartObject.
If the Sale Quantity is edited on the View, the Expressions are updated and reflect the new amounts as shown below.
These values have NOT been updated to the SmartObject. Should the SmartObject need to be updated, click on Save.
It is evident from this example how useful Expressions can be when required to make batch updates. Apply the Expression on the body control and Save in runtime. All records are updated at once.
The second method is to apply the Expression on the Add/Edit Item row’s controls and not the body. This will ensure that only records that have manually been altered will be updated and what is shown on the column is consistent with what is currently saved or will be saved. This will also not alter historical data unless the record itself was edited.
We used the same SmartObject and Editable List View as in the above scenario and just removed the Expression on the body control.
We then clicked on the Add/Edit Item field and added another Expression to multiply the Sale Quantity by 1. We kept the aggregation on the Total Amount field.
When running this View, the values reflected is consistent with what is currently saved.
If the Sale Quantity is edited on the View, the Expressions are applied only to the row(s) edited and reflect the new amounts as shown below:
The altered values have NOT been updated at this point. Should the SmartObject need to be updated, click on Save. Only records that have manually been edited will be updated.