Hi guys, I’m new to X++, I’m having this weird issue, It seems like this.SalesQty value dicreases on every iteration on a loop,
This happens only when i make some calculations on this value, This is my code (located in Tables\SalesLine\Methods\modifiedField):
case fieldNum(SalesLine, DistributionId):
if(this.DistributionId) // check if user filled the field
{
while select distributionsVendors where distributionsVendors.DistributionId == this.DistributionId
{
ttsBegin;
salesLineInsert.SalesId = this.SalesId;
//salesLineInsert.SalesStatus = this.SalesStatus;
salesLineInsert.Invoiceable = NoYes::Yes;
salesLineInsert.ItemId = this.ItemId;
salesLineInsert.SalesCategory = this.SalesCategory;
salesLineInsert.SalesQty = this.SalesQty * (distributionsVendors.Percentage / 100);
salesLineInsert.SalesUnit = this.SalesUnit;
salesLineInsert.SalesPrice = this.SalesPrice * (distributionsVendors.Percentage / 100);
salesLineInsert.LineDisc = this.LineDisc;
salesLineInsert.LinePercent = this.LinePercent;
salesLineInsert.LineAmount = this.LineAmount * (distributionsVendors.Percentage / 100);
salesLineInsert.SalesDeliverNow = this.SalesDeliverNow;
salesLineInsert.createLine(true, true, true, true, true, true);
salesLineInsert.clear(); // Preparing the buffer for the next iteration
info(strFmt(“qte: %1”, this.SalesQty));
this.dataSource().refresh();
this.dataSource().research();
ttsCommit;
}
}
break;
The line salesLineInsert.SalesQty = this.SalesQty * (distributionsVendors.Percentage / 100); changes this.SalesQty value !
Thank you guys in advance .