How add new column who is comming from another datasource ?
You must modify the method modifyQuery who is comming from InventDimCtrl_Frm_OnHand class
public void modifyQuery(
FormDataSource _inventSum_DS,
FormDataSource _inventDim_DS,
FormDataSource _inventBatch_DS = null)
{
#Query
Query query = _inventSum_DS.query();
QueryBuildDataSource qbsSum;
QueryBuildRange criteriaClosed;
QueryBuildRange criteriaClosedQty;
QueryBuildDataSource qbsDim;
QueryBuildRange criteriaInventDim;
QueryBuildRange criteriaItemId;
ListEnumerator enumerator;
FieldId dimFieldId;
FieldId dimParmFieldId;
boolean doHint;
InventDim inventDimMovement;
InventDimParm inventDimParmRange;
InventDimParm inventDimParmGroupBy;
QueryBuildRange qbr;
ProdJournalProd prodJournalProd;
Counter orderByFieldCount;
Counter orderByFieldIdx;
QueryOrderByField orderByField;
str orderByDataSourceName;
FieldId orderByFieldId;
List dimOrderByFields;
boolean anyOrderByFieldToRemove;
if (!callingElement || !callingElement.args())
{
return;
}
qbsSum = query.dataSourceName(_inventSum_DS.name());
inventDimMovement = this.inventDim();
if (callingElement.args().dataset() == tableNum(ProdJournalProd))
{
prodJournalProd = callingElement.args().record() as ProdJournalProd;
qbr = SysQuery::findOrCreateRange(qbsSum, fieldNum(InventSum, ItemId));
qbr.value(queryValue(ProdTable::find(prodJournalProd.ProdId).ItemId));
}
doHint = InventSum::queryAddHintFromCaller(qbsSum,callingElement.args());
query.clearGroupBy();
qbsSum.addGroupByField(fieldNum(InventSum,ItemId));
criteriaClosed = SysQuery::findOrCreateRange(qbsSum, fieldNum(InventSum,Closed));
if (dimParmVisibleGrid.ClosedFlag)
{
criteriaClosed.value('');
}
else
{
criteriaClosed.value(queryValue(NoYes::No));
}
criteriaClosedQty = SysQuery::findOrCreateRange(qbsSum, fieldNum(InventSum,ClosedQty));
if (dimParmVisibleGrid.ClosedQtyFlag)
{
criteriaClosedQty.value(queryValue(NoYes::No));
}
else
{
criteriaClosedQty.value('');
}
qbsDim = query.dataSourceName(_inventDim_DS.name());
doHint = InventDim::queryAddHintFromCaller(qbsDim,callingElement.args()) && doHint;
inventDimParmGroupBy = InventDimParm::orParms(dimParmLockedRightClick, dimParmVisibleGrid);
if (this.movement() && callingElement.name() == formStr(InventOnhandMovement) && inventDimMovement)
{
inventDimParmGroupBy.queryAddGroupByFieldValue(qbsDim, inventDimMovement);
}
else
{
inventDimParmGroupBy.queryAddGroupByField(qbsDim);
}
if(_inventBatch_ds)
{
query.dataSourceName(_inventBatch_ds.name()).addGroupByField(fieldnum(inventBatch,expdate));
query.dataSourceName(_inventBatch_ds.name()).addGroupByField(fieldnum(inventBatch,proddate));
}
if (this.movement())
{
enumerator = this.dimFields().getEnumerator();
while (enumerator.moveNext())
{
dimFieldId = enumerator.current();
dimParmFieldId = InventDim::dim2dimParm(dimFieldId);
if (dimParmLockedRightClick.(dimParmFieldId)
|| (((callingElement.name() == formStr(InventOnhandMovement) && dimParmVisibleGrid.(dimParmFieldId))
|| callingElement.name() == formStr(InventSupply))
&& inventDimMovement.(dimFieldId)))
{
criteriaInventDim = qbsDim.findRange(dimFieldId);
if (!criteriaInventDim)
{
criteriaInventDim = qbsDim.addRange(dimFieldId);
}
criteriaInventDim.value(queryValue(inventDimMovement.(dimFieldId)));
inventDimParmRange.(dimParmFieldId) = NoYes::Yes;
}
else
{
criteriaInventDim = qbsDim.findRange(dimFieldId);
if (criteriaInventDim)
{
criteriaInventDim.value('');
}
}
}
}
// If InventDim ranges being sorted by are no longer visible, then remove the sorting
dimOrderByFields = new List(Types::Container);
orderByFieldCount = query.orderByFieldCount();
for (orderByFieldIdx = 1; orderByFieldIdx <= orderByFieldCount; orderByFieldIdx++)
{
orderByField = query.orderByField(orderByFieldIdx);
orderByDataSourceName = orderByField.dataSource().name();
orderByFieldId = orderByField.fieldID();
if (orderByField.dataSource().table() == tableNum(InventDim))
{
dimParmFieldId = InventDim::dim2dimParm(orderByFieldId);
if (inventDimParmGroupBy.(dimParmFieldId))
{
dimOrderByFields.addEnd([orderByDataSourceName, orderByFieldId]);
}
else
{
anyOrderByFieldToRemove = true;
}
}
else
{
dimOrderByFields.addEnd([orderByDataSourceName, orderByFieldId]);
}
}
if (anyOrderByFieldToRemove)
{
query.clearOrderBy();
// Add remaining fields back
enumerator = dimOrderByFields.getEnumerator();
while (enumerator.moveNext())
{
[orderByDataSourceName, orderByFieldId] = enumerator.current();
query.dataSourceName(orderByDataSourceName).addOrderByField(orderByFieldId);
}
}
if (query.orderByFieldCount() == 0)
{
criteriaItemId = qbsSum.findRange(fieldNum(InventSum, ItemId));
if (!criteriaItemId || criteriaItemId.value() == '')
{
// If no other sorting then add some default sorting
qbsSum.addOrderByField(fieldNum(InventSum,ItemId));
}
}
if (! doHint && ! inventDimParmRange.isFlagSelective() && ! dimParmVisibleGrid.ClosedFlag)
{
qbsSum.addSortIndex(indexNum(InventSum,ClosedItemDimIdx));
qbsSum.indexIsHint(true);
qbsDim.addSortIndex(indexNum(InventDim,DimIdIdx));
qbsDim.indexIsHint(true);
doHint = true;
}
if (doHint)
{
query.literals(#QueryForcePlaceholders);
}
else
{
query.literals(#QueryLiteralsDefault);
}
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.