KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: The Entity selection class .minus() function now supports a keepOrder parameter
PRODUCT: 4D | VERSION: 19 R 7 | PLATFORM: Mac & Win
Published On: June 5, 2023

As of 4D v19 R7, the Entity selection class .minus() function supports a keepOrder parameter. The .minus() function excludes the passed parameter from the entity selection and returns the resulting entity selection.

dk_keep_ordered (integer) is used to keep the initial order in the resulting entity selection.

Example:

var $employees; $result : cs.EmployeeSelection
var $employee : cs.EmployeeEntity

$employees:=ds.Employee.query("lastName = :1";"H@")
// $employees contains entity with primary key 710 and other entities
// for ex. "Colin Hetrick", "Grady Harness", "Sherlock Holmes" (primary key 710)

$employee:=ds.Employee.get(710) // Returns "Sherlock Holmes"

$result:=$employees.minus($employee)
//$result contains "Colin Hetrick", "Grady Harness"

$result2:=$employees.minus($employee; dk_keep_ordered)
// ensure order is kept by passing dk_keep_ordered


Note:

If you pass dk_keep_ordered in keepOrder and the removed entitySelection contains entities duplicated in the original entity selection, all occurrences of the duplicates are removed.

If the original entity selection or both the original entity selection and the entitySelection parameter are empty, an empty entity selection is returned.

If entitySelection is empty or if entity is Null, a new reference to the original entity selection is returned.

If the original entity selection and the parameter are not related to the same dataclass, an error is raised.