Filter Item on PO

LambaLamba Member Posts: 260
Hi,
When we make a PO, on selecting Item as the type, on lookup of Item list in No. field, only those items must be visible/marked those are having a boolean true named Sanct in item table.

As the item list opens on the lookup of the No. field of PO subform, i tried using the below code
on No.'s OnLookup trigger:

item.LOOKUPMODE(TRUE);
IF item.RUNMODAL = ACTION::LOOKUPOK THEN
item.GETRECORD(Sanct);

But didn't worked.

Answers

  • Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    If you always on any purchase line only want to filter on these kind of items you might want to consider changing the table relation.
  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    Before executing the lookup, you need to filter the Item-record on the boolean field: item.SETRANGE(Sanct,TRUE);
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • LambaLamba Member Posts: 260
    i have used itemlist form, so filter the boolean record from the item table, secondly the
    item.GETRECORD(Sanct); part of the code is not working. It says

    Type conversion is not possible because 1 of the operators contains an invalid type.

    Record := Boolean
  • yukonyukon Member Posts: 361
    Hi Lamba,

    Please try with below code.
    //recItem.SETRANGE(Field,Your Filter Value);
    IF NOT recItem.FINDSET THEN EXIT;
    frmItemList.SETRECORD(recItem);
    frmItemList.LOOKUPMODE(TRUE);
    IF frmItemList.RUNMODAL = ACTION::LOOKUPOK THEN
      frmItemList.GETRECORD(recItem);
    Message('%1',recItem."No.");
    

    Noted: If after work above code. Please care above post reply.

    Regards,
    Yukon
    Make Simple & Easy
  • LambaLamba Member Posts: 260
    Hi Yukon,
    Tried the code on OnLookUp trigger of No., field, but the data isn't filtering on lookup still...
    ](*,)
  • yukonyukon Member Posts: 361
    Hi ,

    This will be work.
    //recItem.SETRANGE(Field,Your Filter Value);
    IF NOT recItem.FINDSET THEN EXIT;
    frmItemList.SETRECORD(recItem);
    frmItemList.SETTABLEVIEW(recItem); //Pls put this code.
    frmItemList.LOOKUPMODE(TRUE);
    IF frmItemList.RUNMODAL = ACTION::LOOKUPOK THEN
      frmItemList.GETRECORD(recItem);
    Message('%1',recItem."No.");
    

    Best Regards,
    Yukon :oops:
    Make Simple & Easy
  • LambaLamba Member Posts: 260
    Thanx Yukon.. It worked..Thanx a ton :)
  • LambaLamba Member Posts: 260
    Hi Yukon,
    But it isn't letting me select any item..
  • LambaLamba Member Posts: 260
    Done with selecting item & filtering too:

    recItem.RESET;
    recItem.SETRANGE("Sanct",TRUE);
    IF NOT recItem.FINDSET THEN EXIT;
    IF FORM.RUNMODAL(FORM::"Item List",recItem) = ACTION::LookupOK THEN
    "No." := recItem."No.";
  • kinekine Member Posts: 12,562
    yukon wrote:
    Hi ,

    This will be work.
    //recItem.SETRANGE(Field,Your Filter Value);
    IF NOT recItem.FINDSET THEN EXIT;
    frmItemList.SETRECORD(recItem);
    frmItemList.SETTABLEVIEW(recItem); //Pls put this code.
    frmItemList.LOOKUPMODE(TRUE);
    IF frmItemList.RUNMODAL = ACTION::LOOKUPOK THEN
      frmItemList.GETRECORD(recItem);
    Message('%1',recItem."No.");
    

    Best Regards,
    Yukon :oops:

    Why not simply
    //recItem.SETRANGE(Field,Your Filter Value);
    IF recItem.ISEMPTY THEN EXIT;
    IF FORM.RUNMODAL(0,recItem) = ACTION::LOOKUPOK THEN
      Message('%1',recItem."No.")
    else
      Message('Nothing selected');
    
    :?:
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • yukonyukon Member Posts: 361
    Hi Kine,

    Thanks ...! I must do next time .... :thumbsup:

    Best Regards,
    Yukon
    Make Simple & Easy
Sign In or Register to comment.