Problem with custom lookup

tompynationtompynation Member Posts: 398
Hi, in the purchase order subform i added following code to the lookup trigger of the Item No. field:

IF Type = Type::Item THEN BEGIN
lv_Item.RESET;
lv_Item.SETRANGE(lv_Item."Vendor No.",gv_VendorCode);
IF FORM.RUNMODAL(31,lv_Item) = ACTION::LookupOK THEN BEGIN
VALIDATE("No.",lv_Item."No.");
END;
END;

I fill up the gv_VendorCode like this:

Form - OnAfterGetCurrRecord()
IF "Buy-from Vendor No." <> '' THEN
CurrForm.PurchLines.FORM.SetVendorFilter("Buy-from Vendor No.");

So this makes sure that when i use the lookup i only see the items from that Vendor... When the user press the show all he see's all items.

This works fine but when i try to select an item i get following error:

There is no Item within the filter.
Filters: Vendor No.: '', No.: XXXXXX


XXXXX is the item number that i selected through the lookup...

Anyone knows whats going wrong now?

Answers

  • Marco_FerrariMarco_Ferrari Member Posts: 53
    I cannot understand why you put the C/AL code in the subform and not on the table 39.

    Marco
    Marco Ferrari
    Microsoft Certified Trainer
    Cronus.it
  • tompynationtompynation Member Posts: 398
    Where would i add the code inside the Purchase Line table?

    I dont want to change the lookup functionallity in other forms... Just on the Purchase Form.
  • Marco_FerrariMarco_Ferrari Member Posts: 53
    On the OnLookup trigger of the "No." field, but in any case if you specify what you want to do, then we can help you in a more precise way...
    Marco Ferrari
    Microsoft Certified Trainer
    Cronus.it
  • tompynationtompynation Member Posts: 398
    Well, i just want that when a user is inserting a purchase order line(s)

    that when he looks up the item, that first the lookup form only shows the items who have the corresponding Vendor No with
    the buy from Vendor no. on the header.

    But by pressing show all he should also be able to select items who dont have the Vendor No equally to the Buy from Vendor No.
  • BeliasBelias Member Posts: 2,998
    SetVendorFilter("Buy-from Vendor No.");
    
    -what does this function do?
    -after pressing "show all", are you selecting an item for a vendor which is different from the one in the header?
    -
    But by pressing show all he should also be able to select items who dont have the Vendor No equally to the Buy from Vendor No.
    do you really want this?or you don't want the user to change the filters?
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • tompynationtompynation Member Posts: 398
    allright i got it working like i wanted it now...

    The problem was something that i created myself to test:

    IF (Type=CONST(" ")) "Standard Text" ELSE IF (Type=CONST(G/L Account)) "G/L Account" ELSE IF (Type=CONST(Item)) Item WHERE (Vendor No.=FIELD(Buy-from Vendor No.)) ELSE IF (Type=CONST(3)) Resource ELSE IF (Type=CONST(Fixed Asset)) "Fixed Asset" ELSE IF (Type=CONST("Charge (Item)")) "Item Charge"

    This is the table relation property of the No. field in the Purchase line table.

    Putting it back to the original solved the problem
    IF (Type=CONST(" ")) "Standard Text" ELSE IF (Type=CONST(G/L Account)) "G/L Account" ELSE IF (Type=CONST(Item)) Item ELSE IF (Type=CONST(3)) Resource ELSE IF (Type=CONST(Fixed Asset)) "Fixed Asset" ELSE IF (Type=CONST("Charge (Item)")) "Item Charge"
  • tompynationtompynation Member Posts: 398
    Belias wrote:
    SetVendorFilter("Buy-from Vendor No.");
    
    -what does this function do?
    -after pressing "show all", are you selecting an item for a vendor which is different from the one in the header?
    -
    But by pressing show all he should also be able to select items who dont have the Vendor No equally to the Buy from Vendor No.
    do you really want this?or you don't want the user to change the filters?

    This function just fills up a variable inside the subform... Its the gv_VendorCode that it fills up to filter the lookup form.
    When users presses "Show all" he is able to select an item which Vendor No. does not equal the Buy From vendor No. on the Header. So standard NAV functionallity.

    It works fine now but if you guys have better solution, i'm ready to implement :mrgreen:
  • BeliasBelias Member Posts: 2,998
    -after pressing "show all", are you selecting an item for a vendor which is different from the one in the header?
    exactly what i mean here :mrgreen::mrgreen:
    anyway, why don't you want to use the tbrelation?
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • tompynationtompynation Member Posts: 398
    i cant get it to work with the table relation...
  • BeliasBelias Member Posts: 2,998
    he is able to select an item which Vendor No. does not equal the Buy From vendor No.
    sorry, i didn't see this point...i've got to :shock:
    obviously you can't get it work with TR... :mrgreen:
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • tompynationtompynation Member Posts: 398
    allright, so my first solution is good
Sign In or Register to comment.