Lookup clears variable - requestpage

BeliasBelias Member Posts: 2,998
edited 2010-09-14 in NAV Three Tier
i have a requestpage with a field cdcustcode. under its onlookup trigger, i have the following code:
IF PAGE.RUNMODAL(0,TBCustomer) = ACTION::LookupOK THEN 
  CDCustCode := TBCustomer."No.";
this is pretty straightforward, in my opinon, but if i click the lookup button, and then esc (the lookupok does not take effect) the field is cleared...why? :-k and more important, how can i avoid it?
thanks in advance for your suggestion.
-Mirko-
"Never memorize what you can easily find in a book".....Or Mibuso
My Blog

Answers

  • ReinhardReinhard Member Posts: 249
    don't you want to put the code on the onLookup trigger
  • BeliasBelias Member Posts: 2,998
    sorry, i corrected my previous post. The code was in the lookup, obviously...not in onvalidate #-o
    anyway, the topic is stil open, do you know how to avoid the problem?
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • BeliasBelias Member Posts: 2,998
    i found a way!!! (my memory is not good, but i am pretty sure to have never done something like this up to now :-k i wonder why i need to do it now)
    IF PAGE.RUNMODAL(0,TBCustomer) = ACTION::LookupOK THEN 
      CDCustCode := TBCustomer."No."
    //CODE ADDED
    ELSE
      cdcustcode := text;   //text is the VAR parameter of the onlookup trigger
    
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • QuickWEQuickWE Member Posts: 80
    Belias wrote:
    i found a way!!! (my memory is not good, but i am pretty sure to have never done something like this up to now :-k i wonder why i need to do it now)
    IF PAGE.RUNMODAL(0,TBCustomer) = ACTION::LookupOK THEN 
      CDCustCode := TBCustomer."No."
    //CODE ADDED
    ELSE
      cdcustcode := text;   //text is the VAR parameter of the onlookup trigger
    

    I think ,the answer was in your reply ,the root cause is Onlookup ,the text variable is
    PassByRef value so if you don't have to assigned any value ,the text will return blanks value.
  • BeliasBelias Member Posts: 2,998
    @QuickWE: read carefully the code: the "else" part of the action::lookupok assign "text" to cdcustomer, not viceversa.
    This means that text is actually evaluated with the correct value when pressing "esc" instead of doing lookupok on the lookup page.
    If i MESSAGE(text), nav returns the actual value of the textbox. if i message(cdcustomer) it returns, blank, no matter what
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • QuickWEQuickWE Member Posts: 80
    Belias wrote:
    @QuickWE: read carefully the code: the "else" part of the action::lookupok assign "text" to cdcustomer, not viceversa.
    This means that text is actually evaluated with the correct value when pressing "esc" instead of doing lookupok on the lookup page.
    If i MESSAGE(text), nav returns the actual value of the textbox. if i message(cdcustomer) it returns, blank, no matter what

    I think,your replies is everythings that I means as my previous posts (If you read by carefully :) ).
  • kinekine Member Posts: 12,562
    Right now I do not have the NAV 2009 to loo into, but if it works in same way as on Form, than:

    1) Work with the parameter passed as ref to "set the value"
    2) Do not forget to exit(true) or exit(false) to signal if lookup was done or canceled... ;-)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • BeliasBelias Member Posts: 2,998
    kine wrote:
    Right now I do not have the NAV 2009 to loo into, but if it works in same way as on Form, than:

    1) Work with the parameter passed as ref to "set the value"
    2) Do not forget to exit(true) or exit(false) to signal if lookup was done or canceled... ;-)
    doesn't work like this. (actually, i already tried to use the exits, but i tried another time, who knows) :-k
    IF PAGE.RUNMODAL(PAGE::"All Patient - List",TBPatientTemp3) = ACTION::LookupOK THEN BEGIN
      Text := TBPatientTemp3."No.";
      EXIT(TRUE);
    END ELSE BEGIN
      EXIT(FALSE);
    END;
    
    am i missing something? (just to be sure, i also tried to revert the value of the "exits", but with no luck.)
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
Sign In or Register to comment.