This is the legacy 4D documentation web site. Documentations are progressively being moved to developer.4d.com

Home

 
4D v19.8
entitySelection.extract( )

entitySelection.extract( ) 


 

entitySelection.extract ( propertyPath {; targetPath}{; propertyPath2 ; targetPath2 ; ... ; propertyPathN ; targetPathN}{; option}) -> Result 
Parameter Type   Description
propertyPath  Text in Property path whose values must be extracted to the new collection
targetPath  Text in Target property path or property name
option  Longint in ck keep null: include null properties in the returned collection (ignored by default). Parameter ignored if targetPath passed.
Result  Collection in Collection containing extracted values

The entitySelection.extract( ) method returns a collection containing propertyPath values extracted from the entity selection. 

propertyPath can refer to:

  • a scalar dataclass attribute,
  • related entity,
  • related entities.

If propertyPath is invalid, an empty collection is returned.

This method accepts two syntaxes.

With this syntax, entitySelection.extract( ) populates the returned collection with the propertyPath values of the entity selection.

By default, entities for which propertyPath is null or undefined are ignored in the resulting collection. You can pass the ck keep null constant in the option parameter to include these values as null elements in the returned collection.

  • Dataclass attributes with dataClassAttribute.kind = "relatedEntity" are extracted as a collection of entities (duplications are kept).
  • Dataclass attributes with dataClassAttribute.kind = "relatedEntities" are extracted as a collection of entity selections.

With this syntax, entitySelection.extract( ) populates the returned collection with the propertyPath properties. Each element of the returned collection is an object with targetPath properties filled with the corresponding propertyPath properties. Null values are kept (option parameter is ignored with this syntax). 

If several propertyPath are given, a targetPath must be given for each. Only valid pairs [propertyPathtargetPath] are extracted.

 

Note: Entities of a collection of entities accessed by [ ] are not reloaded from the database.

Example  

Given the following table and relation:

 C_COLLECTION($firstnames;$addresses;$mailing;$teachers)
 C_OBJECT($status)
  //
  //
  //$firstnames is a collection of Strings
 $firstnames:=ds.Teachers.all().extract("firstname")
  //
  //$addresses is a collection of entities related to dataclass Address
  //Null values for address are extracted
 $addresses:=ds.Teachers.all().extract("address";ck keep null)
  //
  //
  //$mailing is a collection of objects with properties "who" and "to"
  //"who" property content is String type 
  //"to" property content is entity type (Address dataclass)
 $mailing:=ds.Teachers.all().extract("lastname";"who";"address";"to")
  //
  //
  //$mailing is a collection of objects with properties "who" and "city"
  //"who" property content is String type 
  //"city" property content is String type 
 $mailing:=ds.Teachers.all().extract("lastname";"who";"address.city";"city")
  //
  //$teachers is a collection of objects with properties "where" and "who"
  //"where" property content is String
  //"who" property content is an entity selection (Teachers dataclass)
 $teachers:=ds.Address.all().extract("city";"where";"teachers";"who")
  //
  //$teachers is a collection of entity selections
 $teachers:=ds.Address.all().extract("teachers")



See also 

collection.extract( )

 
PROPERTIES 

Product: 4D
Theme: ORDA - EntitySelection

 
PAGE CONTENTS 
 
HISTORY 

Created: 4D v18 R3

 
ARTICLE USAGE

4D Language Reference ( 4D v19)
4D Language Reference ( 4D v19.1)
4D Language Reference ( 4D v19.4)
4D Language Reference ( 4D v19.5)
4D Language Reference ( 4D v19.6)
4D Language Reference ( 4D v19.7)
4D Language Reference ( 4D v19.8)