web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

At least one BOM line must be attached to this line

(0) ShareShare
ReportReport
Posted on by 180

Hi Guys,

I´m tyring to post & register a BOM journal in AX 2012 R3, but when I run my code I get this error:

At least one BOM line must be attached to this line.

I think that I missing a link field or somethng like that,

Anyone can help me with this. 

This is the code that I'm using:

journalTable.clear();
journalTable.initValue();
journalTable.initFromInventJournalName(InventJournalName::find(InventParameters::find().BomJournalNameId));
journalTable.JournalId = journalTableData.nextJournalId();
journalTable.insert();

 

journalTrans.clear();
journalTrans.initFromInventJournalTable(journalTable);
journalTrans.initFromInventTable(InventTable::find("22-590-125"));
journalTrans.InventDimId = "NDIM0000007";
journalTrans.Qty = 1;
journalTrans.PriceUnit = InventTableModule::find(journalTrans.ItemId, ModuleInventPurchSales::Invent).pcsPrice();
journalTrans.CostAmount = journalTrans.Qty * journalTrans.PriceUnit;
journalTrans.InventTransId = "LOTE002951085"; 
journalTrans.BOMLine = NoYes::No;
journalTrans.insert();


inventTransId = journalTrans.InventTransId;

journalTrans.clear();
journalTrans.initFromInventJournalTable(journalTable);
journalTrans.initFromInventTable(InventTable::find("22-590-126"));
journalTrans.InventDimId = "NDIM0000007";
journalTrans.Qty = -1*1;
journalTrans.PriceUnit = InventTableModule::find(journalTrans.ItemId, ModuleInventPurchSales::Invent).pcsPrice();
journalTrans.CostAmount = journalTrans.Qty * journalTrans.PriceUnit;
journalTrans.InventTransId = NumberSeq::newGetNum(InventParameters::numRefInventTransId()).num();
journalTrans.TransDate = today();
journalTrans.BOMLine = NoYes::Yes;
journalTrans.InventTransIdFather = inventTransId;
journalTrans.insert();

if(InventJournalCheckPost::newPostJournal(journalTable).validate())

InventJournalCheckPost::newPostJournal(journalTable).run();

Thank you in Advance

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Faisal Fareed Profile Picture
    10,796 User Group Leader on at
    RE: At least one BOM line must be attached to this line

    Have a look on this example; it is working fine www.andesoft.net/creating-bom-journal-using-x-code-ax-2009-ax-2012

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Community Member Profile Picture

Community Member 2

#1
Martin Dráb Profile Picture

Martin Dráb 2 Most Valuable Professional

#1
Guy Terry Profile Picture

Guy Terry 2 Moderator

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans