Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics NAV (Archived)

Filter bincode lookup field using bin columns

Posted on by 200

bincode lookup fields gets the data from bincontents page. But it needs to be filered from a Boolean field name 'block' if its false from bin page. bincode is common for both bin and bincontents page.

For this scenario I got answer from the following link.

community.dynamics.com/.../271416

and the code is

In the BinContent table, add a flowfield called Bin Blocks defined as Lookup(Bin.Blocks WHERE (Location Code=FIELD(Location Code),Code=FIELD(Bin Code))).

Then, in your lookup:

BinContent.SETRANGE(BinContent."Item No.",ItemNo);

BinContent.CALCFIELDS("Bin Blocks");

BinContent.SETRANGE("Bin Blocks",FALSE); //TRUE or FALSE depending on the filter you want to apply

IF PAGE.RUNMODAL(0,BinContent) = ACTION::LookupOK THEN

......

But for same thing bincode lookup filed to filtered from another Boolean field name dedicated(i.e it should get  filterered using two columns). Can anyone suggest?

*This post is locked for comments

  • RE: Filter bincode lookup field using bin columns

    Its working...!!!Thank You very much Stefano....

  • Suggested answer
    Stefano Demiliani Profile Picture
    Stefano Demiliani 37,162 Most Valuable Professional on at
    RE: Filter bincode lookup field using bin columns

    Ok. You can use MARK for this:

    BinContent.SETRANGE(BinContent."Item No.",ItemNo);

    BinContent.SETAUTOCALCFIELDS("Dedicated Blocks","Bin Blocks");

    if BinContent.FINDSET THEN

    REPEAT

    BEGIN

     if (BinContent."Dedicated Blocks" = FALSE) OR (BinContent."Bin Blocks" = FALSE) then

       BinContent.MARK(true);

    END

    UNTIL BinContent.NEXT=0;

    BinContent.MARKEDONLY(TRUE);

    IF PAGE.RUNMODAL(0,BinContent) = ACTION::LookupOK THEN

    ...

  • RE: Filter bincode lookup field using bin columns

    If  Both bin blocks and dedicated blocks is true, those records should not be shown. But your code resembles if the bin blocks is true or dedicated block is true the record is not shown. I am asking in 'And' condition.

    For example I have 3 lines of records A, B, C

    For Case 1, Bin Blocks is True and Dedicated Blocks is False.

    For Case 2,Dedicated Blocks is True and Bin Blocks is False.

    For Case3, both blocks(dedicated and bin) is True. So this line should not be shown. This case is my requirement. For first 2 cases the records should be shown.

    Thanks in Advance.

  • Suggested answer
    Stefano Demiliani Profile Picture
    Stefano Demiliani 37,162 Most Valuable Professional on at
    RE: Filter bincode lookup field using bin columns

    The code provided shows all Bin Content lines where Bin Blocks is false and Dedicated Blocks is false. If this is not what you want, can you explain your requirement? When do you want to see a BinContent record? Under what conditions?

  • RE: Filter bincode lookup field using bin columns

    Your code works for only if dedicated or blocks(anyone) checked, but I need if both checked and that particular bin code should not be shown.

  • Suggested answer
    Stefano Demiliani Profile Picture
    Stefano Demiliani 37,162 Most Valuable Professional on at
    RE: Filter bincode lookup field using bin columns

    The FINDSET cycle is unuseful for filtering.

    You can do exactly like in the previous post:

    BinContent.SETRANGE(BinContent."Item No.",ItemNo);

    BinContent.SETAUTOCALCFIELDS("Dedicated Blocks","Bin Blocks");

    BinContent.SETRANGE("Bin Blocks",FALSE);

    BinContent.SETRANGE("Dedicated Blocks",FALSE);

    IF PAGE.RUNMODAL(0,BinContent) = ACTION::LookupOK THEN

    ...

  • RE: Filter bincode lookup field using bin columns

    I used following code it filters if anyone one Boolean is checked.

    //

    BinContent.SETRANGE(BinContent."Item No.",ItemNo);

    BinContent.CALCFIELDS("Dedicated Blocks");

    BinContent.CALCFIELDS("Bin Blocks");

       IF BinContent.FINDSET THEN

         REPEAT

          BinContent.SETRANGE("Bin Blocks",FALSE);

          BinContent.SETRANGE("Dedicated Blocks",FALSE);

         UNTIL BinContent.NEXT  = 0;

    //

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans