0

I'm new in dynamics365 programming, I want to store in any variable the result of this query:

the tables are: InventDim id; InventTrans it;

while select sum(qty) from it
        where (it.ItemId == "OL-1500") || it.ItemId == "OL-1000"
        join id
        group by inventBatchId
        where id.InventDimId == it.InventDimId 

How I can achieve that?

Jan B. Kjeldsen
  • 17,817
  • 5
  • 32
  • 50
OiRc
  • 1,602
  • 4
  • 21
  • 60

1 Answers1

2

One way is to us a map:

Map ret = new Map(Types::String, Types::Real);
MapEnumrator it = ret.getEnumerator();

while select sum(qty) from it
    where it.ItemId == "OL-1500" || it.ItemId == "OL-1000"
    join id
    group by inventBatchId
    where id.InventDimId == it.InventDimId 
{
    ret.insert(id.InventBatchId, it.Qty);
}

while (it.moveNext())
    info(strFmt("%1: %2", it.currentKey(), it.currentValue()));

Other options:

  • save in a temporary table.
  • create a view, use in form
  • create a query, use in form

It really depends on how you will use the data.

Jan B. Kjeldsen
  • 17,817
  • 5
  • 32
  • 50