Entity Selection as parameter

Dear,

I tried to use an entity selection as parameter $0.
It worked interpreted, but it was not possible to pass the compiler.
So my question is: Can you pass entity selections as parameters, like any other Object?
Or are these Objects specific in some way?

Background
Without ORDA I had a method that generates a selection in another table
The input parameters are (fromFieldPointer;toFieldPointer),
where the first parameter also defined the from table and the second defined the
target table.
Most often it is the “xSeqnr” that are the fields (and it started before pk)

The method “joins” records from 2 tables over a table that I call [LinkTable],
consisting basically of 2 fields: fromxSeqnr and toxSeqnr. It makes it easy to link together
records to other records where there is no structural relation.
Often this mechanism is used to link records from table [Document] to any ofher record(s)
in any other table(s).

Now I’d like to take this to ORDA and I do some simple tests.
During tests I came across that it was not possible with an Entity Selection as $0 parameter (compiled).

Best Regards

Magnus Torell

Hi,

It is possible to pass an entity selection as parameter to a project method.
And a project method can return an entity selection in $0.

What kind of error do you have ?

Here is a small compiled database. I hope it will help.

https://forums.4d.com/4DBB_Main/x_User/21442460/files/34428315.zip

just keep in mind that an entitySelection is C_OBJECT, not C_COLLECTION.

Dear,

Perfectly correct. It works like it should.
I must have made a typo and gotten a bad declaration, when
clicking the “generate typing” from the compiler dialog.

However my apologies for the buzz.

Best Regards

Magnus

Miyako!

When we are at this topic. Excuse me for stealing this thread. What is the best way to generically differ an entity selection object from a regular object. Right now i am using $myObject.length = null (regular object) thus # null is an entity selection. Using v 17.

Hi,

It seems good. I would have done the same.

I don’t know if Keisuke has another idea ?

it seems reasonable.

altertively, you could JSON Stringify.