Hi all,
I have2 datasourcesi want to exclude all fields from datasource 2 (EcoResProduct)
just showing ItemId field in a first datasource (InventTable)this my code
query1 = new query(); qbds = query1.addDatasource(tableNum(InventTable)); qbds.addSelectionField(fieldNum(InventTable,ItemId)); qbds1 = qbds.addDataSource(tableNum(EcoResProduct)); qbds1.relations(true); qbds1.joinMode(JoinMode::InnerJoin);
Please explain what exactly you want to achieve. You talk about showing fields, but you code is about a database query. These are two separate things.
You may want to select fields from database that you won't show in a form or report.
But if you know that you don't need any fields from EcoResProduct and you need this table just for some filters, don't use InnerJoin. Choose ExistsJoin instead.
thank you
I fully agree with goshoom . Here's an example:
static void Job1(Args _args) { InventTable inventTable; ItemId itemId; Query query; QueryBuildDataSource qbsInventTable, qbsEcoResProduct; QueryRun qr; ; query = new Query(); qbsInventTable = query.addDataSource(tableNum(InventTable)); qbsInventTable.addSelectionField(fieldNum(InventTable, ItemId)); qbsEcoResProduct = qbsInventTable.addDataSource(tableNum(EcoResProduct)); qbsEcoResProduct.relations(true); qbsEcoResProduct.joinMode(JoinMode::ExistsJoin); info(query.dataSourceNo(1).toString()); //SELECT ItemId FROM InventTable(InventTable_1) //EXISTS JOIN * FROM EcoResProduct(EcoResProduct_1) // WHERE InventTable.Product = EcoResProduct.RecId qr = new QueryRun(query); while (qr.next()) { inventTable = qr.get(tableNum(InventTable)); itemId = inventTable.ItemId; } }
thanks for this helpfull answer
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 Abhilash Warrier as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
CA Neeraj Kumar 2,028
André Arnaud de Cal... 878 Super User 2025 Season 2
Sohaib Cheema 579 User Group Leader