Thanks Lahav, that works.
I’m using an Entity Selection to display on a Listbox and I needed to include
some related field columns.
Using relation names did the trick.
This is all generic code written a long time ago and I’m upgrading it to
V17+ORDA.
As a thank you for the tip, here is some code to get a Relation name, given 2
related tables…
> C_TEXT($0)
> C_LONGINT($1;$tableNo;$2;$relatedTableNo)
>
> //--- copy parameters to locals
> $tableNo:=$1
> $relatedTableNo:=$2
>
> //--- locals
>
> //--- code
> ARRAY TEXT($aConstraint;0)
> Begin SQL
> select CONSTRAINT_NAME
> from _USER_CONSTRAINTS
> where CONSTRAINT_TYPE = '4DR' and TABLE_ID = :$tableNo and
> RELATED_TABLE_ID = :$relatedTableNo
> into :$aConstraint
> End SQL
> If (Size of array($aConstraint)=1)
> $0:=$aConstraint{1}
> Else
> $0:=""
> End if
> On Jul 30, 2018, at 7:01 PM, lists via 4D_Tech <[email protected]> wrote:
>
> Hi Julio,
>
> You need to name your relations, which then shows up as an entity in your
> collection, containing the related data.
>
> Assuming a table named A and a relation to table B named My_B_Link, after
> loading a selection of table A into collection My_Col, you can get your
> related data from table B like this:
>
> My_Col.My_B_Link.AnyFieldYouLike
>
> Regards,
>
> Lahav
>
> -----Original Message-----
> From: 4D_Tech <[email protected]> On Behalf Of Julio Carneiro via
> 4D_Tech
> Sent: Monday, July 30, 2018 10:18 AM
> To: 4D iNug Technical <[email protected]>
> Cc: Julio Carneiro <[email protected]>
> Subject: ORDA question: how do I add related fields to an entity selection?
>
> Let’s say I have 2 tables in my database, MANY and ONE, where MANY has a many
> to one relation to ONE.
>
> Using a MANY based SELECTION TO ARRAY I can populate arrays with fields from
> the MANY table, of course, but I can also include fields from the ONE table.
> If automatic relations is set to true 4D will resolve the relations
> automatically and populate the arrays accordingly. Works great and I’ve used
> it a LOT :-)
>
> Now, using ORDA, how can I get related fields into an Entity Selection? is
> that possible? looking at the docs I could not find a way to do that. Except
> by manually going thru the selection and manually resolving the relation and
> populating the fields needed.
>
> Maybe that is one of those cases where it is better to stick with the “old
> way” and use Arrays.
>
> --
> Julio Carneiro
> [email protected]
>
>
>
> **********************************************************************
> 4D Internet Users Group (4D iNUG)
> Archive: http://lists.4d.com/archives.html
> Options: https://lists.4d.com/mailman/options/4d_tech
> Unsub: mailto:[email protected]
> **********************************************************************
> **********************************************************************
> 4D Internet Users Group (4D iNUG)
> Archive: http://lists.4d.com/archives.html
> Options: https://lists.4d.com/mailman/options/4d_tech
> Unsub: mailto:[email protected]
> **********************************************************************
--
Julio Carneiro
[email protected]
**********************************************************************
4D Internet Users Group (4D iNUG)
Archive: http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub: mailto:[email protected]
**********************************************************************