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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Help with query to fill grid when form loads

(0) ShareShare
ReportReport
Posted on by 180

Hi, please any help would be greately appreciated!

I'm a newbie to AX 2012 development, trying to customize the All Purchase Requisitions grid, please check attached image1 for what I'm trying to do.

 I've got 3 tables that I need to join so I can display fields from the 3 on a grid for All  Purchase Requisitions, especially fron the WorkflowWorkItemTable that has the name of the person that currently has the requisition for any of the status (closed, riview, approved, draft)

PurchReqTable -> RecID

PurchReqLine -> PurchReqTable

WorkflowWorkItemTable -> RefRecId

The class  PurchReqTableForm  to fill the form, the definition is:

/// <summary>

/// The <c>PurchReqTableForm</c> class controls the behavior of the <c>PurchReqTable</c> form.

/// </summary>

class PurchReqTableForm implements SysSaveable

{

PurchReqTable purchReqTable;

PurchReqId newPurchReqId;

PurchReqLine newlyCreatedPurchReqLine;

PurchReqShowRequisitions showRequisitions;

RecId requisitionerRecId;

HcmWorkerName requisitionerName;

PurchReqRequisitionStatus status;

NoYes statusAll;

QueryBuildRange rangeRequisitioner;

QueryBuildRange rangeStatus;

QueryBuildDataSource joinWorkFlowItemTable;

FormDataSource queryPurchReqTable;

FormDataSource queryPurchReqLine;

FormDataSource queryWorkflowWorkItemTable;

boolean isFormLoading;

QueryBuildDataSource purchReqTableFilterDataSource;

boolean isFilterHeaderOriginator;

PurchReqFormMode purchReqFormMode;

container packedClasses;

ProjTable projTable;

PurchReqShowRequisitionsFilter purchReqShowRequisitionsFilter;

AccountingDistributionView distributionView;

Object purchReqTableFormRun;

#DEFINE.Project('Project')

#define.CurrentVersion(4)

#localmacro.CurrentList

showRequisitions,

status,

statusAll,

requisitionerRecId

#endmacro

}

And the query to fill the grid on the form is below, I do not get any error message after I added the code to join the WorkflowWorkItemTable with the original 2 tables, because this table has the name I want to display on the grid when the form loads:

 

public Query queryPurchTable(FormDataSource _queryPurchReqTable, FormDataSource _queryPurchReqLine, FormDataSource _queryWorkflowWorkItemTable, boolean _isFilterHeaderOriginator)

{

QueryBuildDataSource qbdsTable = _queryPurchReqTable.query().dataSourceTable(tableNum(PurchReqTable));

QueryBuildDataSource qbdsLine = _queryPurchReqLine.query().dataSourceTable(tableNum(PurchReqLine));

QueryBuildDataSource qbdsWorkIT = _queryPurchReqLine.query().dataSourceTable(tableNum(WorkflowWorkItemTable));

rangeRequisitioner = qbdsLine.addRange(fieldNum(PurchReqLine, Requisitioner));

rangeRequisitioner.status(RangeStatus::Locked);

rangeRequisitioner.enabled(false);

rangeStatus = qbdsTable.addRange(fieldNum(PurchReqTable, RequisitionStatus));

rangeStatus.status(RangeStatus::Locked);

this.setStatus(status, statusAll);

queryPurchReqTable = _queryPurchReqTable;

queryPurchReqLine = _queryPurchReqLine;

queryWorkflowWorkItemTable = _queryWorkflowWorkItemTable;

isFilterHeaderOriginator = _isFilterHeaderOriginator;

purchReqShowRequisitionsFilter = PurchReqShowRequisitionsFilter::newPurchReqTable(qbdsTable, qbdsLine, fieldNum(PurchReqLine,Requisitioner), isFilterHeaderOriginator);

purchReqShowRequisitionsFilter.applyFilter(showRequisitions);

purchReqTableFilterDataSource = qbdsTable.addDataSource(tableNum(PurchReqLine));

purchReqTableFilterDataSource = qbdsTable.addDataSource(tableNum(WorkflowWorkItemTable));

purchReqTableFilterDataSource.enabled(false);

purchReqTableFilterDataSource.addLink(fieldNum(PurchReqTable, RecId), fieldNum(PurchReqLine, PurchReqTable));

purchReqTableFilterDataSource.addLink(fieldNum(PurchReqTable, RecId), fieldNum(WorkflowWorkItemTable, RefRecId));

purchReqTableFilterDataSource.joinMode(JoinMode::ExistsJoin);

return _queryPurchReqTable.query();

}

*This post is locked for comments

I have the same question (0)
  • Martin Dráb Profile Picture
    239,840 Most Valuable Professional on at

    If you want to add additional data sources, I would expect you to change the PurchTableListPage query. If you add them at run-time, you won't be able to bound the grid field to a datasource at design-time, will you?

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 Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
CP04-islander Profile Picture

CP04-islander 10

#2
Harisgillani Profile Picture

Harisgillani 4

#2
dserp Profile Picture

dserp 4

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans