0

Trying to automatically link record from one table to open record in another table using a button

First off, I have already been made aware that line 4 is going to do nothing and line 1 probably needs to be changed, that said here is my scenario.

 

When I create a transaction I automatically apply today's date to the date field. 

I have added a reference field from my Transactions table to my Tax Table (N:1). 

When I click the button "Update Tax Table," I would like for the reference field to automatically pull in the record in the tax table that has the Year field match the year of the transaction date. 

I have been trying to follow this method from an older post, thinking that I needed to just update the references somewhat but I am stuck on what exactly I need to update I guess. 

let myTable1 := Id;
let myText := Text;
for i in (select Table2)[Text = myText] do
i.(Table1 := myTable1)
end

 

1 reply

null
    • Fred
    • 1 yr ago
    • Reported - view

    If you are linking the current record to 'Tax Tables' then you can try the following:

    let transId := Id;
    let transYear := number(year(date));
    let taxRec := first(select 'Tax Table' where Year = transYear);
    let 'Tax Table' := taxRec
    

    Since Transactions has a many to 1 relationship to Tax Table you don't need the loop command. You have to use the first() command because Ninox always assumes multi records when doing a select.

Content aside

  • 1 yr agoLast active
  • 1Replies
  • 111Views
  • 2 Following