Use of container in display method in AX
Hi friends, Today am going to
discuss about the use of container in display method in MS dynamics AX.
There may be requirement when
we need to display certain things from multiple lines in to a single field with
comma separated, and it is just for viewing purpose(Sometime informative).
Let us take a quick example
wherein I can show you this functionality working and code behind it!! J
Ex:
In sales header you want to
capture all the lines warehouses in a single field which should be separated in
comma.
Am going to add display method,
Just add the below code in Table > SalesTable
Display Name Warehouse()
{
salesline salesline;
Container warehouse;
int i=0;
str strwarehouse;
;
strwarehouse='';
while select salesline where
salesline.SalesId==this.SalesId
{
if(confind(warehouse,InventDim::find(salesline.InventDimId).InventLocationId)==0)
warehouse
+=InventDim::find(salesline.InventDimId).InventLocationId;
}
for (i = 1 ; i <= conLen(warehouse) ;
i++)
{
if(strwarehouse=='')
strwarehouse=conPeek(warehouse,i);
else
strwarehouse=strwarehouse+',
'+conPeek(warehouse,i);
}
return strwarehouse;
}
And then drag this particular
method in SalesTable form.
And once this display method is
added in to the grid, we will be able to view our scenario.
Here it is:
So, the field ‘warehouse’ in header
part of sales order represents the cumulative warehouse of lines.
Keep reading J
Leave a Comment