Method checkbox in Dynamics AX -Map ssc
Below is the method to select the records which are being selected as a method checkbox in the standard system in AX.
A map needs to be declared initially which needs to be initialized on init.
Map
gSelectedInventSum;
On init
gSelectedInventSum =
new Map(Types::String, Types::Record);
this method needs to be written on the form design to get the selected record.
On selection
public edit boolean
selectInventSum(
boolean _set,
InventSum _inventSum,
boolean _select)
{
boolean inventSumSelected;
InventDim dim = _inventSum.joinChild();
inventSumSelected =
gSelectedInventSum.exists(dim.inventBatchId);
if (_set)
{
if (_select)
{
if (!inventSumSelected)
{
gSelectedInventSum.insert(dim.inventBatchId, dim);
}
}
else
{
if (inventSumSelected)
{
gSelectedInventSum.remove(dim.inventBatchId);
}
}
}
return
gSelectedInventSum.exists(dim.inventBatchId);
}
Inorder to get the selected records on a button click use the below method
void clicked()
{
int ret;
InventDim dim;
InventDimParm dimParm;
MapEnumerator enum;
List receiptList;
super();
enum =
gSelectedInventSum.getEnumerator();
while (enum.moveNext())
{
dim = enum.currentValue();
dim = InventDim::findOrCreate(dim);
info(strFmt("item : %1,dim
%2",inventSum.ItemId,dim.inventBatchId));
}
}
Another way to get the items and process further is as belowpublic int showContextMenu(int _menuHandle)
{
int ret;
inventSumSelector;
receipt;
InventDim dim;
InventDimParm dimParm;
MapEnumerator enum;
List receiptList;
view = gCurrentView;
item = gTree.getTreeItem(this.getSelection());
if (gSelectedInventSum.empty())
{
dim = InventSum.joinChild();
dim = InventDim::findOrCreate(dim);
dimParm.initFromInventDim(dim);
dimParm.InventBatchIdFlag = false;
}
else
{
enum = gSelectedInventSum.getEnumerator();
receiptList = new List (Types::Class);
while (enum.moveNext())
{
dim = enum.currentValue();
dim = InventDim::findOrCreate(dim);
dimParm.initFromInventDim(dim);
receipt = //;
receiptList.addEnd(receipt);
}
}
return ret;
}
No comments:
Post a Comment