web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

excluding all fields from showing in datasource

(0) ShareShare
ReportReport
Posted on by 35

Hi all,

I have2 datasources
i 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);

I have the same question (0)
  • Verified answer
    Martin Dráb Profile Picture
    238,208 Most Valuable Professional on at

    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.

  • suhailbinshuaib Profile Picture
    35 on at

    thank you

  • Janos Kovacs Profile Picture
    130 on at

    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;
        }
    }

  • suhailbinshuaib Profile Picture
    35 on at

    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.

Helpful resources

News and Announcements

Season of Giving Solutions is Here!

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Abhilash Warrier Profile Picture

Abhilash Warrier 763 Super User 2025 Season 2

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 413 Super User 2025 Season 2

#3
Martin Dráb Profile Picture

Martin Dráb 284 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans