0

Syntax to trigger removal of a link between between tables

Greetings: I am trying to break a link between two tables, triggered when certain conditions are met. what is the correct syntax to break a link?

I have two tables, Trips and Locales, and a third table, Visits, which records Trips to the Locale.

Trips : Locales = 1 : n (non-composition).

Locales : Visits = 1 : n (composition).

In Visits, table Trigger-onCreate field, I use this code, which does not work.

let myTrip := TripID;
let myLocale := LocaleID;
let b := last(select Locales where number(Id) = myLocale and number(trips.Id) = myTrip);
b.number(Id := null)

Thanks for your help.

3 replies

null
    • Leonid_Semik
    • 5 yrs ago
    • Reported - view

    Hi Laura,

    the formula to break a link:

    ---

    'Linked field':=0

    ---

    I do not understand your formula. What do you want to achieve with it?

    Leo

    • Laura
    • 5 yrs ago
    • Reported - view

    Perfect! Thank you. 

    I’ll try to get back to you a bit later with more details on what I’m working on.

    • Laura
    • 5 yrs ago
    • Reported - view

    Hi, Leonid, if you mean what were those additional lines of code for, I can see why you were baffled! None of the earlier lines were needed—they were only there because I was flailing around, trying to get something to work when my original line of code:

    'Linked field' := null

    didn't.

    This may be more than you were asking for, but if you mean more broadly what am I trying to achieve with this system, I am building a database that enables business travelers in our small business to select a particular locale, and log their business travel dates there.

    If you live in the US, I'm sure you already know this; business travelers here can use a government-approved per diem rate for business deductions, in lieu of having to keep track of all their travel receipts. To do this, I have a table Trips that stores some info about travel; and Locales, a table of potential travel destinations. Locales has two subtables: Per Diems, which houses IRS-approved per diem rates by year for each city; and Visits, a subtable that keeps track of the dates that the traveler visited that particular locale on business.

    I use a 1:∞ link, non-composition, between Trips and Locales, and a button that allows the user to input dates and use the link search mechanism to select or add their travel destination(s) and dates. At that point, Visits ( ∞:1 with Trips) is visible to the user from the Trips log form, and has a list of the places they've been during that trip, plus their deductible amounts spent versus per diem rates. 

    I break the link between Trips and Locales after each Visits entry, to enable the locale to be used as a destination for a different trip.

     

    -l.

Content aside

  • 5 yrs agoLast active
  • 3Replies
  • 2295Views