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

Notifications

Announcements

No record found.

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,827 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
    237,987 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

Responsible AI policies

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

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 420 Most Valuable Professional

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 241 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans