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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

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

Remove added data source to qbds

(0) ShareShare
ReportReport
Posted on by 332

Hello..

How to remove the data source added to qbds

    [FormDataSourceEventHandler(formDataSourceStr(PurchEditLines, PurchParmLine), FormDataSourceEventType::QueryExecuting)]
    public static void InventDim_OnQueryExecuted(FormDataSource sender, FormDataSourceEventArgs e)
    {
        QueryBuildDataSource    qbds,qbdsUser,qbdsLocation,qbdsInventDim;
        PA_WarehousesUsers      PA_WarehousesUsers;
        InventLocation          inventlocation;
        PurchParmUpdate PurchUpdate;
        PurchParmLine   PurchParmLine;

        FormRun formRun= sender.formRun();
        Object salesline_ds = formRun.dataSource(formDataSourceStr(PurchEditLines, PurchParmUpdate)) as FormDataSource;
        PurchParmUpdate salesline = salesline_ds.cursor();

        str user = curUserId();

        select PA_WarehousesUsers where PA_WarehousesUsers.UserId == user;

        if(PA_WarehousesUsers && salesline.SpecQty == PurchUpdate::All)
        {
            qbds = sender.query().dataSourceTable(tableNum(InventDim));

            qbdsUser = qbds.addDataSource(tableNum(PA_WarehousesUsers));
            qbdsUser.addLink(fieldNum(PA_WarehousesUsers, InventLocationId), fieldNum(InventDim, InventLocationId));
            qbdsUser.addRange(fieldnum(PA_WarehousesUsers, UserId)).value(queryValue(user));

        }
        else
        {
            sender.query().dataSourceTable(tableNum(InventDim)).clearDynalinks();

            FormObjectSet ds = formRun.dataSource(); // caller form's datasource
            ds.reread();
            ds.research(true);

        }
    }

I need to clear just the new data source , clear range now appropriate with me in this case .

Thanks all

  • Suggested answer
    nmaenpaa Profile Picture
    101,172 Moderator on at

    If I understood correctly, you want to clear the range that you added to qbdsUser data source. Correct?

    I recommend to use SysQuery::findOrCreateRange() method instead of qbdsUser.addRange.

    This way you always have exactly one range, and can either set an actual value or '*'value to the range. Or you can still call qbdsUser.clearRanges();

  • Ahmed Osama Ibrahim Profile Picture
    332 on at

    Thanks

    If i remove the range I will have duplication data , so i need to remove the data source from qbds , or rerun the query again without the data source i added

  • Verified answer
    Sergei Minozhenko Profile Picture
    23,099 on at

    Hi Ahmed Osama,

    QueryBuildDataSource class has method enabled and you can disable data source in the query by code:

    qbds.enabled(false);

  • Ahmed Osama Ibrahim Profile Picture
    332 on at

    Thank you

    Thanks all

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the August Top 10 Community Leaders

These are the community rock stars!

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

#1
Martin Dráb Profile Picture

Martin Dráb 555 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 484 Super User 2026 Season 2

#3
CU10121822-0 Profile Picture

CU10121822-0 378

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans