Show form based on temporary table

lzrlzr Member Posts: 264
I have been trying to write a faster item search on the sales lines and here I got a problem.

Somehow I can't get my form to display my temporary table, and it has to be temporary else it can not run in my trigger.

Explanation:
ItemSearch is a temporary table which contains 3 fields, no, description, unit price.

ItemSearchList is a form which displays the ItemSearch records.

I put the following code inside the following trigger on sales line form. "No." - OnAfterInput(Var Text : Text[1024];)
IF Type = Type::Item THEN
BEGIN
  CLEAR(ItemSearchList);
  ItemSearch.DELETEALL;
  ItemTmp.RESET;

  ItemTmp.SETCURRENTKEY("No.");
  ItemTmp.SETFILTER("No.", '%1', UPPERCASE(Text) + '*');
  IF ItemTmp.FIND('-') THEN
  REPEAT
    ItemSearch."No." := ItemTmp."No.";
    ItemSearch.Description := ItemTmp.Description;
    ItemSearch."Unit price" := ItemTmp."Unit Price";
    ItemSearch.INSERT;
  UNTIL ItemTmp.NEXT = 0;
  ItemTmp.SETRANGE("No.");

  ItemTmp.SETCURRENTKEY("Search Description");
  ItemTmp.SETFILTER("Search Description", '%1', UPPERCASE(Text) + '*');
  IF ItemTmp.FIND('-') THEN
  REPEAT
    ItemSearch."No." := ItemTmp."No.";
    ItemSearch.Description := ItemTmp.Description;
    ItemSearch."Unit price" := ItemTmp."Unit Price";
    ItemSearch.INSERT;
  UNTIL ItemTmp.NEXT = 0;

  IF ItemSearch.FIND('-') THEN
    ItemSearchList.SETTABLEVIEW(ItemSearch);

  ItemSearchList.LOOKUPMODE(TRUE);
  IF ItemSearchList.RUNMODAL = ACTION::LookupOK THEN
  BEGIN
    ItemSearchList.GETRECORD(ItemSearch);
    Text := ItemSearch."No.";
  END;
END;

If anyone have any suggestions I'd be grateful
Navision developer

Answers

  • krikikriki Member, Moderator Posts: 9,118
    To run a form on a temptable, the best way is to create and fill up the temptable and then
    FORM.RUNMODAL(FORM::"Your Form",tmpYourTempTable);
    
    In this way you can also use Search, filters on it.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • lzrlzr Member Posts: 264
    Very nice, it works now. My search is sooo fast now :)

    Thank you Kriki, I should have used the search before I asked :oops:
    Navision developer
Sign In or Register to comment.