Copy a reference field into another reference field
Hello,
I’m completely new to Ninox and I’m trying to create a database for my business. It contains Products, Customers and Invoices tables with a Line items subtable of Invoices. So far so good but as well as having a relationship between Invoices - Products and Invoices - Customers I also need to have a relationship between Line items and Customers because I want to see all individual Products that a Customer bought (please see my Data Model).
The problem is that each time I’m creating Line items in an Invoice, I have to select not only the Product but also the same Customer I have already selected for the Invoice, over and over again and that is really frustrating when selecting 50+ products. I think I should be able to copy the Customer name with a script included in trigger after update either table level in Line items table or on the field level when selecting the Product but for the life of me I cannot come up with the script. I have combed through the forum answers but I just can’t find a solution that I could apply to my problem (and even if I did I’m not sure I would be able to modify it to my needs). I would very much appreciate your help!
4 replies
-
In your 'Line Items' table put this code in the 'Trigger after update' box:
Customers := Invoices.Customer
-
Sorry...
Customers := Invoices.Customers
-
Oh my god! Is it really so simple? I was trying to put together complex scripts with let variables and select statements :-) I guess KISS is really the golden rule here. Thank you very much for your time and help!
-
Content aside
- 4 yrs agoLast active
- 4Replies
- 1189Views