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

SalesTableListPage query extension through X++

(0) ShareShare
ReportReport
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:

pastedimage1665737609098v1.png

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

[ExtensionOf(formStr(SalesTableListPage))]
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.clearRanges();
        queryBuildDataSource.addDataSource(tableNum(ACCRestrictCampusDimensionValueVCGPPTTmp_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,

Hein 

I have the same question (0)
  • Verified answer
    GirishS Profile Picture
    27,843 Moderator on at

    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.

    Thanks,

    Girish S.

  • Martin Dráb Profile Picture
    239,118 Most Valuable Professional on at

    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()?

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

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

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 733

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 461 Super User 2026 Season 1

#3
Syed Haris Shah Profile Picture

Syed Haris Shah 278 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans