Auto Populate the Serial No. on the item tracking lines form

snehasneha Member Posts: 191
I’m not going into in detail about the customization. I’m stuck at one point and seeking your help. My need is, I need to AUTO populate the serial number on the sales order item tracking lines form equals to “Sales Order#-Line#” whenever user clicks on the sales order -> Line – Item tracking lines. In which codeunit I can write the code to achieve this?
Sales Line-Reserve, Item Tracking Management,….?

For example, if the sales order is SO1234 and the line number is 10000, the serial number should be populated as SO1234-10000 when user clicks on Sales order -> Line -> Item Tracking Lines

Comments

  • AndwianAndwian Member Posts: 627
    Do you not use Item Tracking (Ser. No.) when receiving or producing goods, i.e. Item Tracking in Inbound Entries?

    Why don't just use "Create Customized SN" function?
    Regards,
    Andwian
  • snehasneha Member Posts: 191
    Thanks for the reply.
    We use Item tracking serial number for the inbound items. If we go indetail, we use kit functionality. As part of the build Kit process on sales order, we need to assign the serial number manually for the kit item. We wanted to automate it by auto populating the serial number as Order No-Line No.
  • AndwianAndwian Member Posts: 627
    sneha wrote:
    As part of the build Kit process on sales order, we need to assign the serial number manually for the kit item. We wanted to automate it by auto populating the serial number as Order No-Line No.
    Why don't setup the Kitting item as non-Item Tracking? That will simplify your process much more.
    Regards,
    Andwian
  • snehasneha Member Posts: 191
    We need to track the serial number for Kit item as well.
  • kinekine Member Posts: 12,562
    The problem is that this "Form" is generic and is used for different documents. It is hard to change the behavior because bad design. Question is: what you will do when the opening of this form will generate new ser. nos., you close it, change the quantity on the sales line, open it again - it should generate new nos. for the added quantity? What about decrease the quantity on the sales line? What you will do with the "not used" serial nos.?
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • snehasneha Member Posts: 191
    I agree. I’m fighting a lot to find an easy way to figure it out.
    In our scenario, each sales line contains only one quantity. When user opens up a Item tracking line form, we should auto populate the serial no as Order No. – Line No. And, user may modify the serial no if needed. When user opens up the item tracking form again, it should show the last modified serial no.
  • kinekine Member Posts: 12,562
    THan what about function over the line, which will in some event generate the needed reservation entry with new serial no.? Skip the form, do it before you open the form itself, do it in some function triggered manually/automatically in some pre-selected event...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • matttraxmatttrax Member Posts: 2,309
    I've done this on the PO side when the order is released. You could do the same for the SO I suppose. I believe that once the serials are there, in order to reduce the quantity, you have to manually go into Item Tracking Lines to delete some lines first. I will try and find the code for it this morning, but I believe you should start by calling functions in the Create Reservation codeunit.
  • BeliasBelias Member Posts: 2,998
    This is my solution, it works (if i've not forgot some piece of code)
    CUCreateReservEntry.SetDates(0D,0D);
    CUCreateReservEntry.SetApplyFromEntryNo(0);
    lTBTrackSpec."Serial No." := Myserialno;  // Document no. + '-' + line no.
    lTBTrackSpec."Serial No. Substituted" := '';
    lTBTrackSpec."Vendor Warranty Date" := 0D;
    lTBTrackSpec."Vendor Lot No." := '';
    lTBTrackSpec."Vendor Serial No." := '';
    CASE INTTableNo OF
      DATABASE::"Purchase Line":
        BEGIN
          CUCreateReservEntry.CreateReservEntryFor(INTTableNo,INTDocType,CDDocNo,'',0,INTLineNo,1,1,CDSerNo,'');
          CUCreateReservEntry.CreateEntry(TBPurchLine."No.",'',TBPurchLine."Location Code",TBPurchLine.Description,0D,0D,0,3);
    .....
    END;
    
    This works for purchase lines. You've to play with tableno, doctype, quantities etc. in order to make it work for the sales lines, too.
    And good luck, as kine said, it's a pain to modify this functionality and i hope this is the only customization you need :mrgreen:
    I know the code is a bit dirty with prefixes etc, but i hope that the names of the variables are understandable. Otherwise, just ask me and i'll provide you the list.
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • matttraxmatttrax Member Posts: 2,309
    CreateReservEntry.SetDates(0D, 0D);
    CreateReservEntry.CreateReservEntryFor(...
    CreateReservEntry.CreateEntry(...

    Where CreateReservEntry is Codeunit 99000830. When doing it through code I recommend creating one manually and one via code then comparing the reservation entries directly. It's really easy to miss something.
  • snehasneha Member Posts: 191
    Thank you all. All your ideas are very helpful for me to start…
Sign In or Register to comment.