Announcements
Hi Experts,
I have a customized form which has two data sources Header Table and Line Table. When I create a record in my form and select the salesId in a field in the header part it should show the lines associated with the salesId in the bottom (Line table) of the form. I was trying to get it done using below code in the modified method of the field salesId in the datasource. I am not sure if this is the proper way to do it and I have an issue here that if i select the same salesid multiple times before saving the record it will create unnecessary records in the line table since the insert is called each time when the field is modified. what is the best way to achieve it ?
public void modified()
{
SalesTable salesTable;
Salesline salesLine;
super();
select salesTable where salesTable.salesId == MyTable.salesId;
MyTable.salesId = salesTable.salesId
MyTable.CustReference = salesTable.custReference
while select salesLine where salesLine.salesId
{
MyTable.salesId = salesLine .salesId
MyTable.ItemId = salesLine.ItemId
MyTable.insert();
}
}
modified is not the right place for this operation. The user did not save the record. He/she can change the selection, or completely abandon it, etc.
You can write it in the insert method of the table. Also, if you open the salesLineRecId field on the line and add a check before creating the record, you will prevent duplicate records.
Hi!
Is there a reason why you're using a custom table instead of the original (SalesLine) as a datasource?
I think what you need is to link both parent and child datasource, in order to show the data related to the SalesLine in the details.
That can be done by associating header and lines in the datasources properties. Select the lines datasource, and on the properties, select the header datasource as Join Source.
Another thing I would do is just use the original SalesLine table as datasource, if this is only for displaying purposes.
André Arnaud de Cal...
294,095
Super User 2025 Season 1
Martin Dráb
232,866
Most Valuable Professional
nmaenpaa
101,158
Moderator