Hi, please any help would be greately appriciated!
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:
///
/// The PurchReqTableForm class controls the behavior of the PurchReqTable form.
///
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
)
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();
