I'm facing an issue in while Generate Picking List, the item line is not coming in the form.
Although I'm calling the below code but I'm not understanding the logic used for
SalesLine.createLine() method.
NumberSeq numberSeq = NumberSeq::newGetNum(SalesParameters::numRefSalesId());
salesid = numberSeq.num();
InventLocationId warehouse = range.get_item(row, 14).value;
str id = salesid;
salesTable.clear();
salesTable.initValue(SalesType::Sales);
salesTable.SalesId = salesid;
salesTable.CustAccount = range.get_Item(row, 22).value;
salesTable.CurrencyCode = range.get_item(row, 33).value;
salesTable.ReceiptDateRequested = range.get_item(row, 1).value;
salesTable.DeliveryName = range.get_item(row, 3).value;
salesTable.DeliveryPostalAddress = range.get_item(row, 4).value;
salesTable.ShippingDateRequested = range.get_item(row, 2).value;
salesTable.ShippingDateConfirmed = range.get_item(row, 5).value;
salesTable.ReceiptDateConfirmed = range.get_item(row, 6).value;
salesTable.InventSiteId = range.get_item(row, 13).value;
salesTable.SalesName = range.get_item(row, 23).value;
salestable.InvoiceAccount = range.get_item(row, 25).value;
salesTable.CustomerRef = range.get_item(row, 26).value;
salesTable.CustomerRefDate = range.get_item(row, 27).value;
salesTable.TransporterName = range.get_item(row, 31).value;
salesTable.DlvMode = range.get_item(row, 32).value;
salesTable.Freight = range.get_item(row, 36).value;
salesTable.VehicleNumber = range.get_item(row, 37).value;
salestable.TransportDate = range.get_item(row, 38).value;
salesTable.BankName = range.get_item(row, 39).value;
salesTable.modifiedField(fieldNum(salesTable, InventSiteId));
salesTable.modifiedField(fieldNum(salesTable, InventLocationId));
salesTable.LanguageId = Range.get_Item(row, 44).value;
salesTable.initFromCustTable();
select custTable
where custTable.AccountNum == range.get_Item(row, 22).value;;
salesTable.CustGroup = custTable.CustGroup;
if (InventLocation::find(warehouse).InventLocationId)
{
salesTable.InventSiteId = InventLocation::find(warehouse).InventSiteId;
salesTable.InventLocationId = InventLocation::find(warehouse).InventLocationId;
}
salesTable.insert();
select forupdate salesTable
where salesTable.SalesId == id;
salesTable.DlvMode = dlvmode;
salesTable.update();
salesLine.clear();
salesLine.initValue(salesTable.SalesType);
salesLine.initFromSalesTable(salesTable);
salesLine.SalesId = salesid;
salesLine.ItemId = range.get_item(row, 7).value;
salesLine.Name = InventTable::find(itemid).NameAlias;
salesLine.SalesQty = range.get_item(row, 9).value;
salesLine.RemainSalesPhysical = salesLine.SalesQty;
salesLine.SalesUnit = range.get_item(row, 10).value;
salesLine.QtyOrdered = salesLine.salesPurchLineInterface().calculateQuantityOrdered(salesLine.SalesQty);
salesLine.RemainInventPhysical = salesLine.QtyOrdered;
salesLine.SalesPrice = range.get_item(row, 11).value;
salesLine.SalesDeliverNow = range.get_item(row, 12).value;
salesLine.LineDisc = range.get_item(row, 16).value;
salesLine.LinePercent = range.get_item(row, 17).value;
salesLine.DlvMode = range.get_item(row, 32).value;
inventDim = salesLine.inventDim();
InventDim.wMSLocationId = Range.get_Item(row, 15).value;
InventDim.InventSiteId = salesLine.inventDim().InventSiteId;
InventDim.InventLocationId = salesLine.inventDim().InventLocationId;
Saleslineinventdim = InventDim::findOrCreate(InventDim);
salesLine.InventDimId = Saleslineinventdim.inventDimId;
salesLine.setInventDimId(Saleslineinventdim.inventDimId,Saleslineinventdim);
salesLine.SalesStatus = SalesStatus::Backorder;
salesLine.LineAmount = salesLine.calcLineAmount(qty);
salesLine.createLine(false, // validation
false, // initFromSalesTable
false, // initFromInventTableModule
false, // calcInventQty
true, // searchMarkup
false, // searchPrice
ItemReservation::Automatic, // checkReservation
false, // skipCreditLimitCheck
false, // ignoreSalesTableInventDim
true, // setLineNum
false); // searchAgreementLine
salesLine.validateWrite();
select forUpdate salesLine_IN
where salesLine_IN.SalesLine == salesLine.RecId;
if (salesLine_IN.RecId)
{
salesLine_IN.AssessableValue_IN = salesLine.LineAmount ;
salesLine_IN.AssessableValueTransactionCurrency = salesLine.LineAmount ;
salesLine_IN.update();
}
else
{
salesLine_IN.clear();
salesLine_IN.initValue();
salesLine_IN.SalesLine = salesLine.RecId;
salesLine_IN.AssessableValue_IN = salesLine.LineAmount ;
salesLine_IN.AssessableValueTransactionCurrency = salesLine.LineAmount ;
salesLine_IN.insert();
}