0
votes

I have a codeunit that has the Production Order Line table as the source and the On Run trigger shows these two lines of code:

ProdOrderLine.GET(Status,'xxxx',10000);
ExecuteFunction(ProorderLine);

The XXXX represents the Production Order No. but someone hard coded it in as you can see. How do I call this codeunit else where (say on a form) but by reference depending on which Production Order line I am on? I tried doing the SetRANGE routine or calling the codeunit.run method directly and so far have no luck. Help!!

2
Wich version of NAV?, but it does not depend on the way you have filter any table.Jonathan Bravetti

2 Answers

4
votes

Open the codeunit, or a copy of it for testing, in design mode and set the table no. property of the codeunit. Then you can refer to the record passed to codeunit.run as Rec within the OnRun function.

The way you pass in the record varies, but one way is to use this syntax:

Codeunit.RUN(CodeUnitNumber, Record)

SetRange will not be sufficient on the passed in variable because it only filters, but doesn't choose a record. You will not need the ProdOrderLine.GET within OnRun, if I understand your problem correctly. Just call ExecuteFunction(Rec).

You don't mention version numbers or what the ExecuteFunction function does, but give this a try.

You can find more information at: https://msdn.microsoft.com/en-us/library/dd301214(v=nav.90).aspx and https://msdn.microsoft.com/en-us/library/dd355035(v=nav.90).aspx

It's been a few years since I developed for Navision, and I don't have a way of testing anymore. Hopefully this will point you in the correct direction, and I haven't forgotten anything critical.

0
votes

Depending upon whether or not the primary key for the Production Order Line table is in fact [Status], [Order No.], [Line No.] you would need to use FIND ('-') or FINDSET depending on which version of NAV.

It appears the line no is also hard coded....does this process only concern itself with the first line of the order?

Are you interested in the Order No. Or Document No.?

In any case I would write it as a conditional statement unless you prefer an error message is returned to the UI if the filter results in 0 rows:

 IF ProdOrderLine.GET(Status,"Order No.", "Line No.") THEN
   ExecuteFunction(ProdOrderLine);