X++ code to filter PurchTableListPage form ( here it filters only today's Purchase order)
Hi Folks,
Today lets say about how to filter PurchTableListPage form.
Note: here it filters only today's Purchase order
just goto PurchTableListPageInteraction Class >>initializeQuery()
and write below code which is highlighted below,
Keep Daxing :) !!!
public void initializeQuery(Query _query)
{
Query query;
QueryBuildDataSource qbds;
QueryBuildRange rangeCompanyId;
QueryBuildRange rangeUserId;
QueryBuildRange rangeId;
QueryBuildRange rangeStatus,qbr;
ProjInvoiceTable projInvoiceTable;
ProjTable projTable;
if (EP::isVendor())
{
EPQuery::makeMyVendorSelfServiceQuery(_query, tableNum(PurchTable));
}
// added by shiva
if(this.listPage().listPageArgs().menuItemName()==menuitemDisplayStr(PurchTableListPage))
{
qbr = _query.dataSourceTable(tableNum(PurchTable)).addRange(fieldNum(PurchTable,CreatedDateTime));
qbr.value(queryValue(today()));
}
// ended by shiva
super(_query);
if (this.listPage().listPageArgs() &&
this.listPage().listPageArgs().externalRecord() &&
this.listPage().listPageArgs().menuItemName() == menuitemDisplayStr(PurchTableListPage) &&
this.listPage().listPageArgs().externalRecord().TableId == tableNum(PurchRFQTable))
{
purchRFQTable = this.listPage().listPageArgs().externalRecord() as PurchRFQTable;
this.applyPurchRFQRange(_query, purchRFQTable);
}
else if (this.getListPageType() == PurchTableListPage::AssignedToMe)
{
qbds = _query.dataSourceTable(tableNum(PurchTable)).addDataSource(tableNum(WorkflowWorkItemTable));
qbds.joinMode(JoinMode::ExistsJoin);
qbds.addLink(fieldNum(PurchTable, RecId), fieldNum(WorkflowWorkItemTable, RefRecId));
qbds.addLink(fieldNum(PurchTable, TableId), fieldNum(WorkflowWorkItemTable, RefTableId));
rangeStatus = qbds.addRange(fieldNum(WorkflowWorkItemTable, Status));
rangeStatus.value(queryValue(WorkflowWorkItemStatus::Pending));
rangeStatus.status(RangeStatus::Locked);
rangeCompanyId = qbds.addRange(fieldNum(WorkflowWorkItemTable, CompanyId));
rangeCompanyId.value(queryValue(curext()));
rangeCompanyId.status(RangeStatus::Locked);
rangeUserId = qbds.addRange(fieldNum(WorkflowWorkItemTable, UserId));
rangeUserId.value(queryValue(curUserId()));
rangeUserId.status(RangeStatus::Locked);
//The Id-range is only used to lock the query from the Ui
rangeId = qbds.addRange(fieldNum(WorkflowWorkItemTable, Id));
rangeId.status(RangeStatus::Locked);
rangeId.enabled(false);
}
else if (this.listPage().listPageArgs() &&
this.listPage().listPageArgs().externalRecord() &&
this.listPage().listPageArgs().menuItemName() == menuitemDisplayStr(PurchTableListPageProject) &&
this.listPage().listPageArgs().externalRecord().TableId == tableNum(ProjInvoiceTable))
{
projInvoiceTable = this.listPage().listPageArgs().externalRecord();
qbds = _query.dataSourceTable(tableNum(PurchTable)).addDataSource(tableNum(ProjTable));
qbds.relations(true);
qbds.joinMode(JoinMode::ExistsJoin);
qbds.addRange(fieldNum(ProjTable,ProjInvoiceProjId)).value(queryValue(projInvoiceTable.ProjInvoiceProjId));
}
else if (this.listPage().listPageArgs() &&
this.listPage().listPageArgs().externalRecord() &&
this.listPage().listPageArgs().menuItemName() == menuitemDisplayStr(PurchTableListPageProject) &&
this.listPage().listPageArgs().externalRecord().TableId == tableNum(ProjTable))
{
qbds = _query.dataSourceTable(tableNum(PurchTable));
qbds.clearDynalinks();
projTable = this.listPage().listPageArgs().externalRecord();
qbds = _query.dataSourceTable(tableNum(PurchTable)).addDataSource(tableNum(PurchLine));
qbds.relations(true);
qbds.joinMode(JoinMode::ExistsJoin);
qbds.addRange(fieldNum(PurchLine,ProjId)).value(queryValue(projTable.ProjId));
}
}
Comments
Post a Comment