Notifications
Announcements
No record found.
I have a grid on a form that has custInvoiceTrans as a data source. I want to add the sales line.
Here's the problem:
If I add the sales line to the form through the UI, it does not link it correctly:
But if I link on the init method of CustInvoiceTrans, then I do not seem to have the option of adding sales line fields to the Grid (based to CustInvoiceTrans)
Thank you
Hi,
May I know when you add SalesLine link to the init method of CustInvoiceTrans, do you also add that datasource with join on form design?
If you want to add salesline to the grid, you might add it in form design first, then use code to get that DS and link to CustInvoiceTrans and then you can drag the field from Salesline ds to the grid.
Regards,
I tried adding it to the form data source and set the link on the init method of CustInvoiceTrans. I get an error if I set join source and it does not see the table if I do not set join source.
I could add the sales line first, but I need fields from both tables on the Grid.
It's difficult to help you if you tell us mere "I get an error". Please show us your code and tell us which error you got and where.
Here's the set up:
Here's the code:
[DataSource] class SalesLine { /// /// /// public void init() { QueryBuildDataSource qbds; QueryBuildDataSource qbds_SalesLine,qbds_CustInvoiceTrans; super(); qbds_SalesLine = SalesTable_ds.query().dataSourceTable(tableNum(SalesLine)); qbds_CustInvoiceTrans = qbds_SalesLine.addDataSource(tableNum(CustInvoiceTrans)); qbds_CustInvoiceTrans.addLink(fieldNum(SalesLine,InventTransId),fieldNum(CustInvoiceTrans,InventTransId)); qbds_CustInvoiceTrans.joinMode(JoinMode::InnerJoin); } }
Here's the result:
It's only pulling the first invoice ID
You have a CustInvoiceTrans data source in the form, but your code doesn't add a relation to it. Your code adds an additional data source to the query, which has nothing to do with the form data source. Therefore your code has no impact on CustInvoiceTrans data source.
If you want to work with the query used by CustInvoiceTrans data source, refer to it by CustInvoiceTrans_ds.queryBuildDataSource(). Don't create a second data source for CustInvoiceTrans.
Ok Thanks, but do I need to add the SalesLine to the CustInvoiceTrans data Source like this:
If i do, then it add a relation (the wrong one)
Yes, configure JoinSource and LinkType in data source properties.
Use clearLinks() (of the QueryBuildDataSource object for CustInvoiceTrans data source) to remove existing links and then use addLink() (as you do in your code).
Under review
Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
Martin Dráb 592 Most Valuable Professional
André Arnaud de Cal... 478 Super User 2025 Season 2
BillurSamdancioglu 305 Most Valuable Professional