I'm still fairly new to x++ development. I'm trying to add some validation to the SalesOrderLineEntity to stop users importing qty's that are not divisible by multiple qty.
This is how far I've gotten, I can't workout how to write in x++ (if ordered qty not divisible by multiple qty (i.e. not whole number)) then throw an error.
[ExtensionOf(tableStr(SalesOrderLineEntity))]
final class SalesOrderLineEntity_Extension
{
boolean validateWrite()
{
InventItemSalesSetup inventItemSalesSetup;
SalesLine salesLine;
SalesTable salesTable = SalesTable::find(this.SalesOrderNumber);
select firstonly * from salesLine where salesLine.salesid == salesTable.SalesId
join inventItemSalesSetup where inventItemSalesSetup.ItemId == salesLine.ItemId;
if (this.RecId)
{
if (salesLine.QtyOrdered < inventItemSalesSetup.MultipleQty)
{
return checkFailed
("qty ordered less than multiple qty");
}
if (isInteger(salesLine.QtyOrdered / inventItemSalesSetup.MultipleQty))
{
return checkFailed
("qty ordered not divisible by multiple qty");
}
}
next validateWrite();
if (!salesTable.checkUpdate(true, true, true))
{
return false;
}
boolean ret;
//ret = super();
return ret;
}
}