Options

Problems with OnLookup trigger

OrangePieOrangePie Member Posts: 11
Hi,
I'm quite new to NAV and while trying to filter the OnLookup list I stumbled across some difficulties. I want to limit the number of possible choices, let's say workers, when unrolling the OnLookup list on page. I tried following the guide that seemed to help to achieve a similar result though it didn't quite work for me.
Could anyone point me in the right direction? I played with some built-in functions but a simple SETRANGE doesn't seem to do the trick.

Comments

  • Options
    SanderDkSanderDk Member Posts: 497
    If you post you code it will be a help to understanding your questen.
    What version of NAV/BC are you using?
    For help, do not use PM, use forum instead, perhaps other people have the same question, or better answers.
  • Options
    OrangePieOrangePie Member Posts: 11
    I'm on 2013. There isn't much code to show since it's been only some functions that I tested.
    Say I have a table and one of its fields is related to data in another table. On page I want to filter the OnLookup list to show only those options in that field that have a certain parameter set to TRUE.
    I tried applying some filters but to no avail.
    After writing the post I found this though: https://forum.mibuso.com/discussion/2588/filtering-a-lookup
    Can you at least explain to me where tblItem came from? is it built-in? I didn't find any information in my materials.
  • Options
    ShaiHuludShaiHulud Member Posts: 228
    tblItem is a "Record" type variable with subtype "Item" (points to "Item" table);
    Some field - OnLookup() //written in table object
    MyTable.SETRANGE("Filter Field", TRUE); //set your filter on the target table
    IF PAGE.RUNMODAL(0, MyTable) = ACTION::LookupOK THEN 
      //RUNMODAL means it will be run "on top", i.e. you won't be able to progress until you are finished with the new window
      //parameter 0 means that it must open page specified in the table's (MyTable) "Lookup Page ID" property
      //parameter MyTable points to the record we want to open the page with (specific filtered table)
      //ACTION::LookupOK means that we will only execute the below code if the page is closed by pressing "OK" button at the bottom-right
      VALIDATE("Some Field", MyTable."Target Field"); //this is because you most likely want to save the value you looked up, in this case to the "Some Field"
    
  • Options
    OrangePieOrangePie Member Posts: 11
    Thanks for the succint answer, I've got it now.
  • Options
    krikikriki Member, Moderator Posts: 9,096
    [Topic moved from 'NAV/Navision Classic Client' forum to 'NAV Three Tier' forum]

    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


Sign In or Register to comment.