how to make load id filter able on sales line in D365 FO

 What we have to do create a view of sales line 

in view add inventTransId

and one Coumputed column LoadId


than write this computed method in this 

 public static server str lastLoadId()

 {

     SysDictTable WHSLoadLineDT = new SysDictTable(tableNum(WHSLoadLine));

 

     DictView dv = new DictView(tableNum(SalesLineLoadIdView));

 

     str s = strFmt('SELECT TOP 1 %1 FROM %2 WHERE %2.%3 = %4 AND %2.%5 = %6 ORDER BY %7 DESC',

     WHSLoadLineDT.fieldName(fieldNum(WHSLoadLine, LoadId), DbBackend::Sql),

     WHSLoadLineDT.name(DbBackend::Sql),

     WHSLoadLineDT.fieldName(fieldNum(WHSLoadLine, InventTransId), DbBackend::Sql),

     dv.computedColumnString(tableStr(SalesLine), fieldStr(SalesLine, InventTransId), FieldNameGenerationMode::WhereClause),

     WHSLoadLineDT.fieldName(fieldNum(WHSLoadLine, InventTransType), DbBackend::Sql),

     SysComputedColumn::comparisonLiteral(InventTransType::Sales),

     WHSLoadLineDT.fieldName(fieldNum(WHSLoadLine, LoadId), DbBackend::Sql));

 

     return strFmt('ISNULL((%1), \'\')', s);

 }

than define the reation in sales line with this view

InventTransId = InventTransId



Than add this view on form 

add outer join with sales line 

from this view use the load id 

it will return the last Load id  becauce we need the last one 



Comments

Popular posts from this blog

How to Bypass Next in COC in D365 X++

create movement journal through code in d365 FO x++