Open Forum

Expand all | Collapse all

Select Bin by Lot in AL extension

  • 1.  Select Bin by Lot in AL extension

    Posted May 07, 2019 01:27 AM
    I'm working on an extension which will help the user select a lot while using the Item Journal. I need to limit the lots I suggest to the user to lots that are present in the bin the user has selected.

    I have tried to do this using the Bin Contents record but filtering by lot number doesn't work. Note that the following code is in a procedure that is called for each lot number which the item has (surely not the most efficient solution but I am only dealing with one or two lots at this stage).
    binContents.SetFilter("Lot No. Filter", Format(itemLedgerEntry."Lot No."));
    binContents.SetRange("Location Code", itemJournalLine."Location Code");
    binContents.SetRange("Bin Code", itemJournalLine."Bin Code");
    binContents.SetRange("Item No.", itemJournalLine."Item No.");
    binContents.SetRange("Variant Code", itemJournalLine."Variant Code");
    binContents.SetRange("Unit of Measure Code", itemJournalLine."Unit of Measure Code");

    exit(binContents.FindFirst());

    Is there a different way of getting this information?


    ------------------------------
    Jessica Robertson
    Software Engineer
    Taska Prosthetics
    ------------------------------


  • 2.  RE: Select Bin by Lot in AL extension

    Posted May 08, 2019 09:37 AM
    You're on the right track. ​The Quantity field on the Bin Content table is a FlowField, not a stored value, so at some point you need to calculate the field or it'll always return 0.

    IF binContents.FINDFIRST THEN
        binContents.CALCFIELDS(Quantity);

    ------------------------------
    Morgan Heller
    Agropur Ingredients
    ------------------------------



  • 3.  RE: Select Bin by Lot in AL extension

    Posted May 09, 2019 02:22 AM
    Thanks for the response! I still can't seem to get it to work though. I tried replacing that last bit I had with the following:

    if binContents.FindFirst() then begin
        binContents.CalcFields(Quantity);
        exit(binContents.Quantity > 0);
    end;

    But it still always returns false (0 Quantity in the debugger). I also tried binContents.CalcQtyBase() but that didn't work either.


    ------------------------------
    Jessica Robertson
    Taska Prosthetics
    ------------------------------



  • 4.  RE: Select Bin by Lot in AL extension

    Posted May 09, 2019 09:23 AM
    Are you positive that you have quantity of that item/lot/variant in that bin? Did you try setting the filters in the client to see if you get a result? I would try passing in hard-coded values to make sure it isn't something wrong with your item journal line record. I'm still on 2017 but the BC documentation on the CALCFIELDS method looks the same.

    Good luck!

    ------------------------------
    Morgan Heller
    Agropur Ingredients
    ------------------------------



  • 5.  RE: Select Bin by Lot in AL extension

    Posted May 09, 2019 06:38 PM
    I removed the line below and the available quantity for the bin was calculated correctly.

    binContents.SetFilter("Lot No. Filter", Format(itemLedgerEntry."Lot No."));

    But I still need to be able to see which lot(s) the available quantity is coming from. Is there another way that I could filter by Lot No when the Quantity FlowField is calculated?


    ------------------------------
    Jessica Robertson
    Taska Prosthetics
    ------------------------------



  • 6.  RE: Select Bin by Lot in AL extension

    Posted May 10, 2019 09:37 AM
    ​The lot filter looks correct - that's how I've always done it and it's working for me. I would guess that there's something off with your lot no. variable. Have you checked its value in debugger? Also, you shouldn't need to format your lot no. I don't see why it would cause a problem, but I'd try removing the format method.

    ------------------------------
    Morgan Heller
    Agropur Ingredients
    ------------------------------



  • 7.  RE: Select Bin by Lot in AL extension

    Posted May 21, 2019 12:37 AM
    Edited by Jessica Robertson May 22, 2019 12:03 AM
    I've removed the format method and it didn't make a difference. I still haven't managed to figure out the problem.

    The value of the Lot No I am trying to get is the string 'L00075'.

    I've tried commenting some of the other filters out to make sure that isn't the problem.

    Turns out lot tracking hadn't been set up correctly.


    ------------------------------
    Jessica Robertson
    Taska Prosthetics
    ------------------------------



If you've found this thread useful, dive deeper into User Group community content by role