Hi experts,
I'm using NAV 2015 and have created a purchase table with some purchase lines.
Now I need to register one or more Serial numbers and/or Lot numbers regarding one of the lines. How do I do that using C/SIDE code?
I have tried this, but it doesn't create anything:
// I have found the purchLine
doFullReserve := TRUE;
reservationManagement.SetPurchLine(purchLine);
reservationManagement.AutoReserve(doFullReserve, purchLine.Description, WORKDATE, purchLine."Outstanding Quantity", purchLine."Outstanding Qty. (Base)");
I think AutoReserve() cannot find my purchHeader.
It would be really great if someone can give an example where more Serial numbers or Lot numbers can be saved to the same purchase line.
Hi Teddy,
Thank you very much for your help. It is great.
Best regards,
Morten
Hi Morten,
You don't need to follow it. The reservation entry is just there to put the serial number and lot number. If you don't need anything, just leave it blank. It could be as simple as:
TempReservEntry.Init();
TempReservEntry."Entry No." := 1;
TempReservEntry."Lot No." := 'ABC';
TempReservEntry.Quantity := 1;
TempReservEntry."Expiration Date := Today();
TempReservEntry.Insert();
This is also based on BC, not older NAV. So the parameter may not be the same.
Hi Teddy,
The first time, you mention TempReservEntry in your code, it just uses the field "Expiration Date". Where is that field assigned?
It is the same, when you call CreateReservEntryFor. You uses TempReservEntry, but never find it or assign values to it.
It's a temporary record called Reservation Entry.
TempReservEntry: Record "Reservation Entry" temporary;
Hi Teddy,
Thank you for your reply.
In your code, there are a few things, I don't understand.
I guess that "TempReservEntry" is a temporary version of the Reservation Entry table. But I don't have that record and in the "SetDates" function, I must use the field TempReservEntry."Expiration Date". And I use fields from the same record later also.
How do I find/create the TempReservEntry before I use the code, you have given me?
Best regards,
Morten
Hi Andy,
Thank you.
Best regards,
Morten
This is an example for Business Central, but you can modify it for NAV 2015.
CreateReservEntry: Codeunit "Create Reserv. Entry";
with PurchLine do begin
CreateReservEntry.SetDates(0D, TempReservEntry."Expiration Date");
CreateReservEntry.CreateReservEntryFor(
Database::"Purchase Line", "Document Type",
"Document No.", '', 0, "Line No.", "Qty. per Unit of Measure",
TempReservEntry.Quantity, TempReservEntry.Quantity * "Qty. per Unit of Measure", TempReservEntry);
CreateReservEntry.CreateEntry(
"No.", "Variant Code", "Location Code", '', "Expected Receipt Date", 0D, 0, ReservStatus::Surplus);
end;
Hello - We currently do not have dedicated Dev support via the Dynamics 365 Business Central forums, but I wanted to provide you some additional resources to assist. If you need assistance with debugging or coding I would recommend discussing this on one of our communities.
dynamicsuser.net/.../developers
I will open this up to the community in case they have something to add.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156