Better entity selection creator

If a table pointer is passed to a method, is there a way to get an entity selection from the table without using EXECUTE FORMULA,

$tableName:=Table name($tablePointer)
EXECUTE FORMULA("$0:=ds."+$tableName+".all()")

and without disturbing the classic current selection in order to use Create entity selection
similar to the way an entity selection can be acquired if a field name is known?

$field2:=Field name(->$fieldPointer)
$tent:=$tent.query($field2+" = :1";“A”)

Thanks,

Hi Keith,

In answer to your 2-questions:

: Keith CULOTTA

[I]s there a way to get an entity selection from the table without
using EXECUTE FORMULA…

Yes, instead of EXECUTE METHODE use ORDA directly, like this:

<code 4D>
C_OBJECT($entitySelection)
$entitySelection:=ds[$tableName].all()
</code 4D>

: Keith CULOTTA

[W]ithout disturbing the classic current selection in order to use
Create entity selection…

ORDA Entity selections and classic 4D current selections are independent of each other.

In classic 4D, the scope of the current selection is the current process.

In order, an entity selection is stored in a 4D Object. The scope of the entity selection is the entity selection object variable’s scope.

This means you have multiple, different entity selections for the same table (ie, dataClass in ORDA) at the same time.

Best regards,
Jeremy

Last sentence above should actually read:

This means you can have multiple, different entity selections for the same table (ie, dataClass in ORDA) at the same time.

: Keith CULOTTA

If a table pointer is passed to a method, is there a way to get an
entity selection from the table without using EXECUTE FORMULA,
$tableName:=Table name($tablePointer)
EXECUTE FORMULA("$0:=ds."+$tableName+".all()")
Hi Keith,
yes, simply use bracket notation instead of dot:
<code 4D>
$tableName:=Table name($tablePointer)
$result_o:=ds[$tableName].all()
</code 4D>

With a field:
<code 4D>
$field_p:=->[MY_TABLE]myField
$attribute_t:=Field name($field_p)
$dataclass_t:=Table name($field_p)
$query_t:=$attribute_t+" = :1"
$value_t:=“a@”
$result_o:=ds[$dataclass_t].query($query_t;$value_t)
</code 4D>

Oops, sorry Jeremy, I read too fast to see you had answered already about brackets.

Jeremy, Arnaud,

Thanks for the examples.
It would have taken a while to guess the ds[$textVar].all() syntax using the brackets and text variable.
I see a similar example in the Design manual under Dataclasses: ds.Company[“revenues”], so now I’m getting how it works.

Regards,