0

Creating new link from a N:N relationship

Hi all -

My Results table has a link to Riders and Horses. I have another table (Ownership) that also has a link to Riders and Horses.

Currently in Results I select a Rider and Horse for each record. I want to switch to selecting a Horse through Ownership. I have over 4000 records that then need to be updated.

I can't wrap my head around how to create a button that will create the proper link.

I can only think of how to do 1 field:

let curRec := this;
let xho := select Ownership where Horse.HorseID = curRec.Horses.HorseID and Riders.RiderID = curRec.Riders.RiderID; <= not sure this is needed
Ownership.Horse.HorseID := curRec.Horses.HorseID

but it needs to match on both the Riders.RiderID and Horse.HorseID.

Thanks,

1 reply

null
    • Fred
    • 3 yrs ago
    • Reported - view

    In case anyone is wondering here is the basic code to create a new reference field link from two other reference field links:

    let xInfo1 := Link1; <--first reference field link
    let xInfo2 := Link2; <--second reference field link
    NewLinkFieldName := first(select NewLinkTableName where NewTableLink1 = xInfo1 and NewTableLink2 = xInfo2) <--This is where a new third reference field linked using data from the first two.

    NewLinkFieldName = the name of the reference field in the table, most like the same as the table name

    NewLinkTableName = the actual name of the Table that new reference field refers to. Again most likely the same name as the field but it may not be

    NewTableLink1 and 2 = in the newly linked Table are reference fields that are the same as in the table you are transferring data from.

    Then you have to wrap it in a first because the NewLinkTable is a N:N table. So theoretically the one search can return many records even if your data is not setup to have duplicates.

Content aside

  • 3 yrs agoLast active
  • 1Replies
  • 436Views