I’m trying to take the SalesID
from the active record in the SalesTable
form and insert it into a custom table. The custom table should be associated with the SalesTable
form. Could anyone guide me on how to achieve this?
I’d appreciate any help on how to retrieve the SalesID
and perform the insert operation properl
The simplest example:
MyTable myTable;
myTable.SalesId = salesTable.SalesId;
myTable.insert();
Nevertheless the real code will likely be more complex. For instance:
- You may want to check if
salesTable.SalesId
has a value.
- You’ll want to call
validateWrite()
of your table and insert the record only if it returns true
.
- If you have more fields to take from
SalesTable
, the usual design pattern is doing it initFromSalesTable()
method.
- My code above assumes that it runs inside a form with
SalesTable
data source, but you’ll often want to put your code somewhere else, such as a class called through a menu item button.
thank you martin for helping me out and it resolve my issue