Side effects are performed in the back end. However, you need to annotate the side effects implemented in the back end using side effect annotations to "inform" the front end which fields on the UI are influenced by a change, so that the front end can request new data for these fields. Otherwise, the UI may still display outdated data.
Default side effects are relevant for most apps. You do not need to annotate these side effects. They are available by default and cannot be switched off.
The following side effects are available in SAP Fiori elements by default:
User Action |
Side Effect |
---|---|
Creating a new entity or draft version, either in the list report or on the object page |
List binding of the parent page is refreshed to show the newly created entity. |
Deleting an entity, either in the list report or on the object page |
List binding of the parent page is refreshed to remove the deleted entity. |
Creating a draft for an active object |
List binding of the list report page is refreshed to show the new draft. |
Discarding a draft version |
List binding of the list report page is refreshed to remove the draft and show the active version. |
Activating a draft version |
List binding of the list report page is refreshed to remove the draft and show the active version. |
Triggering an action |
After executing an action successfully, the collection for which the action is defined is refreshed automatically if the following conditions apply:
You can annotate side effects on actions. |
A side effect annotation includes the following elements:
Side effect source: A property change, an action, or a structural change (creating or deleting a subitem).
Side effect target: A property or structural information.
TriggerAction
(optional): The value of this property
denotes the path to a function import that needs to be executed when the
side effect is triggered.
The TriggerAction
replaces the
PreparationAction
property that is deprecated
as of the SAPUI5 1.87
release.
The EffectTypes
property is deprecated as of the
SAPUI5
1.84 release.
The following side effect annotations are supported:
Source properties
If you use a value help, combo box, checkbox, date picker, or date-time picker, the side effect is triggered as soon as the value is set. However, if you are typing the value, the side effect is triggered when the focus moves away from the field. If the aforementioned controls are used in combination with other input fields as a source for a side effect, then the side effect is triggered only when the focus moves away from the source field group.
For SAP Fiori elements for OData V2:
You can define a single property or a list of properties as a source, forming a virtual field group.
When you modify the source property and move the focus away from the source, the side effect is triggered.
When you modify the virtual field group and move the focus away from it, the side effect
is triggered
immediately
if no TriggerAction
is configured in the
side effect annotation. However, if the focus is changed to
a control within the same virtual field group, then the side
effect is not triggered.
You cannot use navigation properties as source properties.
Source entities
You can specify a navigation property:
In SAP Fiori elements for OData V2: Only a 1:n navigation property can be specified as the source entity.
In SAP Fiori elements for OData V4: Any kind of navigation property (1:1 or 1:n) can be specified as the source entity. Side effects can be executed in the following contexts:
You cannot specify a 1:1 association or an empty target, such as NavigationPropertyPath
, to ensure that the whole
entity is considered as the source.
The side effect is triggered by structural changes such as adding or deleting an item. With SAP Fiori elements for OData V4, it is also triggered when any property of an entity changes, whereas with SAP Fiori elements for OData V2, it is not. Instead, the side effect must be defined in the entity type of the associated entity.
Target properties
You can define a property or a list of properties to be refreshed.
You can also use 1:1 navigation properties. If this is the case, a
request with a $expand
to this navigation property
is triggered.
You must always enclose the type
of
TargetProperties
within quotes. For more
information, see Side Effect Type.
Target entities
You can specify 1:1 and 1:n navigation properties.
If you specify an empty target, the whole entity is updated.
If a trigger action is defined but the
TargetProperties
or
TargetEntities
are not defined, then only the
trigger action is called.
As a general rule, no data is sent to the back end until the UI validation errors are solved. This means that the side effect isn't triggered when there are validation errors related to the source property or a set of properties.
For example, if a data field referencing the ProductCategory
or
MainProductCategory
property has a field value entered with
greater than MaxLength="40"
, no side effect is triggered. Both
properties are successfully validated to trigger the side effect.
<EntityType Name="SEPMRA_I_ProductCategoryType" sap:label="Category" sap:content-version="1"> <Key> <PropertyRef Name="ProductCategory"/> </Key> <Property Name="ProductCategory" Type="Edm.String" Nullable="false" MaxLength="40" sap:label="Category"/> <Property Name="MainProductCategory" Type="Edm.String" MaxLength="40" sap:label="Main Category" sap:value-list="fixed-values"/> <NavigationProperty Name="to_MainCategory" Relationship="STTA_PROD_MAN.assoc_BBDC3EA034F824A7382F8EEF561C1160" FromRole="FromRol e_assoc_BBDC3EA034F824A7382F8EEF561C1160" ToRole="ToRole_assoc_BBDC3EA034F824A7382F8EEF561C1160"/> </EntityType>
<Annotations Target="NAMESPACE.ENTITYTYPE"> <Annotation Term="com.sap.vocabularies.Common.v1.SideEffects" Qualifier="ProductChanged"> <Record> <PropertyValue Property="SourceProperties"> <Collection> <PropertyPath>ProductCategory</PropertyPath> <PropertyPath>MainProductCategory</PropertyPath> </Collection> </PropertyValue> <PropertyValue Property="TargetEntities"> <Collection> <NavigationPropertyPath></NavigationPropertyPath> </Collection> </PropertyValue> </Record> </Annotation> </Annotations>