The entitySelection.add( ) function adds the specified entity to the entity selection and returns the modified entity selection.
Note: This method modifies the original entity selection.
Warning: The entity selection must be non-shareable, i.e. it has been created for example by dataClass.newSelection( ) or Create entity selection, otherwise entitySelection.add( ) will return an error. Shareable entity selections do not accept the addition of entities. For more information, please refer to the Shareable vs Alterable entity selections paragraph.
The entity is added depending on the entity selection is ordered or not (see Ordered vs Unordered entity selections):
- If the entity selection is ordered, entity is added at the end of the selection. If a reference to the same entity already belongs to the entity selection, it is duplicated and a new reference is added.
- If the entity selection is unordered, entity is added anywhere in the selection, with no specific order.
The modified entity selection is returned by the function, so that function calls can be chained.
An error occurs if entity and the entity selection are not related to the same dataClass. If the entity to be added is Null, no error is raised.
Calls to the function can be chained:
var $sel : cs.ProductSelection
var $p1;$p2;$p3 : cs.ProductEntity
$p1:=ds.Product.get(10)
$p2:=ds.Product.get(11)
$p3:=ds.Product.get(12)
$sel:=ds.Product.query("ID > 50")
$sel:=$sel.add($p1).add($p2).add($p3)