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 

  • Martin Dráb Profile Picture
    231,884 Most Valuable Professional 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
    27,823 Moderator 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.

    Thanks,

    Girish S.

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February 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... 293,099 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,884 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Product updates

Dynamics 365 release plans