I have 2 warnings displayed, saying Company and Lot Id need to get filled up, while trying to update my sales line. I am sure inside my SalesLine, I have the Lot Id being filled up. However, I have no idea what Company is AX trying to refer to, because I cannot find such a field in the SalesLine table.
In my requirement, I need to create Sales order and sales line, without knowing the inventory (such as sites, etc).
I have created my sales order successfully through X++, but not for Sales Line. Below is the code which creates both the Sales order and the sales line. Please shed me some light to what is exactly wrong. Thanks in advance.
public SalesTable createSalesTable()//(HISLedgerJournalImport _hISLedgerJournalImport)
{
SalesTable salesTable;
SalesFormLetter salesFormLetter;
HISLedgerJournalImport hisLedgerJournalImport;// = _hISLedgerJournalImport;
info("Start inserting records into SalesTable");
while select hisLedgerJournalImport
where hisLedgerJournalImport.HISCategory == HIS_SALESCATEGORY
{
str tmpSalesId = hisLedgerJournalImport.HISSalesDeptId + "-" + hisLedgerJournalImport.HISSalesId;
if (!SalesTable::exist(tmpSalesId))
{
info("Inserting record: " + int642Str(hisLedgerJournalImport.RecId));
salesTable.SalesId = tmpSalesId;
salesTable.initValue();
salesTable.CustAccount = hisLedgerJournalImport.LedgerJournalTrans_HISAccount;
salesTable.initFromCustTable();
//salesTable.initFromCustTableMandatoryFields();
salesTable.CurrencyCode = hisLedgerJournalImport.LedgerJournalTrans_CurrencyCode;
salesTable.LanguageId = CompanyInfo::languageId(); //Grabbing not from the cust table, but from companyInfo
salesTable.insert();
this.createSalesLine(salesTable, hisLedgerJournalImport);
}
}
return salesTable;
}
public void createSalesLine(SalesTable _salesTable, HISLedgerJournalImport _hISLedgerJournalImport)
{
SalesTable salesTable = SalesTable::find(_salesTable.SalesId);
SalesLine salesLine;
HISLedgerJournalImport hisLedgerJournalImport;
while select hisLedgerJournalImport
where hisLedgerJournalImport.HISSalesDeptId == _hISLedgerJournalImport.HISSalesDeptId &&
hisLedgerJournalImport.HISSalesId == _hISLedgerJournalImport.HISSalesId
{
salesLine.SalesId = salesTable.SalesId;
//salesLine.initValue();
//salesLine.initFromSalesTable(salesTable);
salesLine.ExternalItemId = hisLedgerJournalImport.HISSalesExternalItemId;
salesLine.Name = hisLedgerJournalImport.HISSalesItemTxt;
salesLine.SalesCategory = EcoResCategory::findByName(HIS_SALESCATEGORY,
EcoResCategoryHierarchyRole::getHierarchiesByRole
(EcoResCategoryNamedHierarchyRole::Sales).RecId).RecId;
salesLine.SalesQty = hisLedgerJournalImport.HISSalesOrderedQty;
salesLine.SalesPrice = hisLedgerJournalImport.HISSalesPrice;
salesLine.LineAmount = hisLedgerJournalImport.HISSalesLineAmount;
salesLine.createLine(true, true, true, true, true, false);
}
}