web
You’re offline. This is a read only version of the page.
close
Skip to main content
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
    236,353 Most Valuable Professional on at
    RE: excluding all fields from showing in datasource

    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
    RE: excluding all fields from showing in datasource

    thank you

  • Janos Kovacs Profile Picture
    130 on at
    RE: excluding all fields from showing in datasource

    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
    RE: excluding all fields from showing in datasource

    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

Quick Links

Responsible AI policies

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

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

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

#1
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 2,028

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 579 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans