Skip to main content

Notifications

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

  • suhailbinshuaib Profile Picture
    35 on at
    RE: excluding all fields from showing in datasource

    thanks for this helpfull answer

  • 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

    thank you

  • Verified answer
    Martin Dráb Profile Picture
    232,858 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.

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,069 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,858 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Product updates

Dynamics 365 release plans