Could someone explain the differences and the correct usages of the different newRecord() functions? Under what circumstances do I use controller.newRecord(), foundset.newRecord() and relationName.newRecord()?
Thanks,
Steve in L.A.
Could someone explain the differences and the correct usages of the different newRecord() functions? Under what circumstances do I use controller.newRecord(), foundset.newRecord() and relationName.newRecord()?
Thanks,
Steve in L.A.
Hi Steve
I don’t know the answer (unfortunatly) but I am interested to hear it as well.
Best regards, Robert
SteveInLA:
Could someone explain the differences and the correct usages of the different newRecord() functions? Under what circumstances do I use controller.newRecord(), foundset.newRecord() and relationName.newRecord()?Thanks,
Steve in L.A.
controller.newRecord() and foundset.newRecord() work the same - you can use either.
When you use foundset.newRecord() - you can add records without affecting the UI (the user doesn’t necessarily see the new record created). Good when you want to do things “in the background.”
relation.newRecord() works the same as above - except it adds a new record to the child table and automatically fills in the primary key for the new child record. For example - if you have a relation called “cust_to_invoice” based on the custID in customers and the custID in orders - and you use cust_to_invoice.newRecord() - Servoy will add the record to invoices and fill out the custID of the current customer.
Hope this helps.
relation.newRecord() is what confuses me the most (lately). Lets say I have a clients table and an invoices table and a relationship that links the two called clients_to_invoices. What steps need to be taken to assure that the desired client_id is inserted into the invoice’s client_id column? Does the method that has this function need to be attached to a form of the clients table and the desired record be selected in that form’s foundset? Can I use a global relationship and if so, does it matter what form the method is running from? If I have multiple forms for the invoices table, what determines the form where the new record appears? I have tried to answer many of the questions myself, but after a while the room starts spinning and I wake up in unusual places, but that’s a different problem.
Steve in LA