Hello!
I have made a CodeUnit that I want to use to insert an Item Journal Line. I am using the CodeUnit to insert and validate the Order No. and Item No. This works well, however, when I want to insert an Operation No., I get this error:
/The field Operation No. of table Item Journal Line contains a value (10) that cannot be found in the related table (Prod. Order Routing Line)./
This comes as a result of this line:
OutputJournalLine.Validate(/Operation No./, '10');
I have hardcoded 10 now to simplify it, but this value will primarily be 10, 20 or 30. When I manually add a line in Business Central, I have to add the Order No. first, then Item No., and then I can insert the Operation No., I am using this same order in my Codeunit:
Later on in the code I set OutputJournalLine./Order No./ := OrderNo; and so on, and then I do OutputJournalLine.Insert() and Commit();
I have a PowerApps app that sends a JSON object, and everything works fine, except for this Operation No. insert.
I can see that the Routing No. is different depending on which Order No. and Item No. I insert, but the Operation No. 10 is consistent, and is the number that gets inserted in the cell if I press one of the lines in Business Central.
If I don't validate the Operation No. I can insert whatever I want into the field, but of course I want to validate it.
What am I missing or doing wrong?