Skip to main content



No record found.

Dynamics 365 Community / Forums / Finance forum / SalesTableListPage que...
Finance forum

SalesTableListPage query extension through X++

Posted on by 20

G'day experts,

I'm currently struggling with an issue related to the SalesTableListPage query that is used on the SalesTableListPage form.

I'm trying to join a temporary table to the SalesTableListPage query based on records with a certain value linked to a financial dimension. When extending the existing SalesTableListPage query and adding the new temp table on SalesTable.SalesId == TmpTable.SalesId the records are correctly filterd but I need to do this through conditions in X code related roles linked to the current user.

Essentially, I need to do this, but conditionally in code:


The code I've tried so far assuming that it should happen on FormDataSourceEventType::QueryExecuting:

final class ACCSalesTableListPage_Extension

    [FormDataSourceEventHandler(formDataSourceStr(SalesTableListPage, SalesTable), FormDataSourceEventType::QueryExecuting)]
    public static void SalesTable_OnQueryExecuting(FormDataSource sender, FormDataSourceEventArgs e)

        QueryBuildDataSource  queryBuildDataSource;

        queryBuildDataSource = sender.query().dataSourceTable(tablenum(SalesTable));
        queryBuildDataSource.addLink(fieldnum(SalesTable, SalesId),fieldnum(ACCRestrictCampusDimensionValueVCGPPTTmp_SalesTable, SalesId));



What am I missing here because the query doesn't seem to execute at all not even with an error?

Kind regards,


  • Martin Dráb Profile Picture
    Martin Dráb 225,783 Super User on at
    RE: SalesTableListPage query extension through X++

    You definitely shouldn't add an extra ACCRestrictCampusDimensionValueVCGPPTTmp_SalesTable data source every time when the form query executes, such as when user filters or sorts the records. It should be done just once, when initializing the form.

    By the way, why don't you simply add a table relation instead of using addLink()?

  • Verified answer
    GirishS Profile Picture
    GirishS 27,828 Super User on at
    RE: SalesTableListPage query extension through X++

    Hi Hein Marx`,

    Refer the sales table list page interaction class. In the initializeQuery method they will be adding the ProjTable to the query based on the condition. You can refer to that. You can create COC for initializeQuery method and add you temp table as datasource.

    Interaction class will be mapped at SalesTableListPage form properties.

    ClassName : SalesTableListPageInteraction.

    Method name: initializeQuery.


    Girish S.

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .


André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 288,459 Super User

Martin Dráb Profile Picture

Martin Dráb 225,783 Super User

nmaenpaa Profile Picture

nmaenpaa 101,148


Featured topics

Product updates

Dynamics 365 release plans