Lookup question

TimoBoTimoBo Member Posts: 31
Hi,

I have a custom table with a field named 'Filtertext'. This field has the following code:

Filtertext - OnLookup(VAR Text : Text[1024];) : Boolean
Text += LookupTable;
exit(true);

I want this field to act like a standard lookup in Navision. Meaning, if the user highlights the text in the field, and chooses a different text by using the lookup, the highlighted text must be replaced by the lookup text.

For example:

Filtertext is TEST
User highlights the text TEST.
User pushes F6 and chooses the text HELP
Filtertext is TESTHELP -> this is wrong because it should be HELP

Can anyone help me?

Comments

  • kapamaroukapamarou Member Posts: 1,152
    Try:
    Text := LookupTable;
  • TimoBoTimoBo Member Posts: 31
    kapamarou wrote:
    Try:
    Text := LookupTable;

    I only want to replace the text if the text is highlighted.
  • SogSog Member Posts: 1,023
    There is no variable that I know of that contains the current highlighted tekst.
    And as follows your wanted functionality is impossible to implement in NAV.
    |Pressing F1 is so much faster than opening your browser|
    |To-Increase|
  • TimoBoTimoBo Member Posts: 31
    But all the lookup fields on the request forms of reports in Navision act this way? So it must be possible in Navision.
  • SogSog Member Posts: 1,023
    That's not because the value is highlighted, you can test it out, dont highlight the value and press the lookup button
    You'll notice that the row you're on contains the value on the request form.
    And partial highlights (for example you have selected customer 10005 and you highlight 10, you'll still end on 10005)
    |Pressing F1 is so much faster than opening your browser|
    |To-Increase|
  • krikikriki Member, Moderator Posts: 9,110
    When I need some special lookup I can't use the tablerelation for, I use this code:
    CLEAR(recTheTable); // I ALSO want to clean the primary-key fields. Otherwise I use RESET;
    recTheTable.SETCURRENTKEY("The key you want");
    recTheTable.SETRANGE("all the filters",...);
    IF recTheTable.GET(primary key fields) THEN ; // Get the record if a previous record was available
      // the primary key fields : should be the field on which you do the lookup (and optionally some other fields)
    IF FORM.RUNMODAL(0,recTheTable) = ACTION::LOOKUPOK THEN
      "The Field" := recTheTable."Primary Key Field";
    
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • TimoBoTimoBo Member Posts: 31
    I just tried it out again in Navision 5.0:

    -Run report 206
    -Enter filter No.: I09-000001 (Or whatever your default numbering is)
    -Highlight I09, and choose I09-000002 with the lookup

    Result: filter No.: I09-000002-000001

    If you highlight I09-000001 completely and then choose I09-000002 with the lookup, the result is I09-000002

    If you don't highlight anything, the result is I09-000001I09-000002

    My question is: what code is behind this function? How do I create the same function?
  • matteo_montanarimatteo_montanari Member Posts: 189
    TimoBo wrote:
    I just tried it out again in Navision 5.0:

    -Run report 206
    -Enter filter No.: I09-000001 (Or whatever your default numbering is)
    -Highlight I09, and choose I09-000002 with the lookup

    Result: filter No.: I09-000002-000001

    If you highlight I09-000001 completely and then choose I09-000002 with the lookup, the result is I09-000002

    If you don't highlight anything, the result is I09-000001I09-000002

    My question is: what code is behind this function? How do I create the same function?

    Hi

    try

    Text := Text + "your value to add";
    EXIT(TRUE);

    on onlookup trigger

    Bye

    Matteo
    Reno Sistemi Navision Developer
  • BeliasBelias Member Posts: 2,998
    Ok, then you want your functionality to behave like standard requestfilterfields.
    I think that it's not possible...this is managed by the executable, not by code.
    Personally, I've never used the return value in the onlookuptrigger (Eto's Post)...maybe that is the solution..
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • TimoBoTimoBo Member Posts: 31
    I'm also starting to think it's not possible...

    I already tried exit(true) and exit(false), without any result.
  • matteo_montanarimatteo_montanari Member Posts: 189
    Post removed ;)

    Matteo
    Reno Sistemi Navision Developer
  • BeliasBelias Member Posts: 2,998
    personally, i've never used the "+=" operator with strings:
    the problem is that we can't have a lookup work as the requestfilterfields...TimoBo explained what he wants sufficiently clear (i think).
    if the user highlights the entire text, the value have to be overwritten, otherwise, the value will be queued
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • Slawek_GuzekSlawek_Guzek Member Posts: 1,690
    Text += LookupTable;
    "+=" operator does not work with text/code fields.

    Regards,
    Slawek
    Slawek Guzek
    Dynamics NAV, MS SQL Server, Wherescape RED;
    PRINCE2 Practitioner - License GR657010572SG
    GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
  • David_SingletonDavid_Singleton Member Posts: 5,479
    To me it seems what you are trying to do is to emulate the property "ClearOnLookup". This property is set on the control on the form, and setting "NO" makes lookup work the same as in the report request form. Just remember not to set this property to NO if you are validating the lookup at the field level in the table.

    Basically setting this to "no" means you can drill down and add multiple parts in a field, to make it easy to do things like Location filter = 'RED|BLUE|WHITE' though F6.

    Is this what you are looking for?
    David Singleton
  • BeliasBelias Member Posts: 2,998
    To me it seems what you are trying to do is to emulate the property "ClearOnLookup". This property is set on the control on the form, and setting "NO" makes lookup work the same as in the report request form. Just remember not to set this property to NO if you are validating the lookup at the field level in the table.

    Basically setting this to "no" means you can drill down and add multiple parts in a field, to make it easy to do things like Location filter = 'RED|BLUE|WHITE' though F6.

    Is this what you are looking for?
    Wow!never used this property!Thank you!
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • David_SingletonDavid_Singleton Member Posts: 5,479
    FYI from OnLine help:

    ClearOnLookup
    Use this property to tell the system to delete the current contents of the field before it adds the value the user selects via the lookup.

    Applies to
    Fields, text boxes

    Settings
    The ClearOnLookup settings are:

    To...
    ... Choose...


    Replace the current contents of the field
    ... Yes (default for all fields except FlowFilter fields)

    Paste into the current contents of the field \
    ... No (default if a FlowFilter field)
    David Singleton
  • David_SingletonDavid_Singleton Member Posts: 5,479
    Belias wrote:
    Thank you!
    You're welcome, I hope it solves your problem.
    David Singleton
  • BeliasBelias Member Posts: 2,998
    Belias wrote:
    Thank you!
    You're welcome, I hope it solves your problem.
    Eheh...it's not a problem of mine :) , as you can say from the first post
    I am only grateful to have you teach me one more thing :wink:
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
Sign In or Register to comment.