Open Forum

Expand all | Collapse all

NAV C/AL Coding Question - Lookup on a Report Request Page

Jump to Best Answer
  • 1.  NAV C/AL Coding Question - Lookup on a Report Request Page

    TOP CONTRIBUTOR
    Posted Mar 09, 2018 11:55 AM

    Hi Everyone.

     

    I could use some C/AL help.

     

    I have a table and the first two fields, SubjectID (Code 20) and Issue (Text 20), make up the Key.

     

    So the data might look like this:

     

    SubjectID   Issue

    ======== =====

    SOP-100     New

    SOP-100     1

    SOP-100     2

     

    I have a report with a request page. On the request page, there is a lookup to the table to select the SubjectID and Issue.

    The lookup places only the value of the SubjectID into the lookup variable. How can I get it to also grab the value of the Issue field?

    #NAV2013R2
    #DeveloperorDBA

    ​​

    ------------------------------
    Lewis Rosenberg
    IT Manager
    Mars Fishcare
    Chalfont PA



    NAVUG Board of Advisors, Programming
    NAVUG Programming Committee
    NAVUG Membership Committee
    ------------------------------


  • 2.  RE: NAV C/AL Coding Question - Lookup on a Report Request Page
    Best Answer

    TOP CONTRIBUTOR
    Posted Mar 09, 2018 04:16 PM
    your table's is e.g. table50000.
    add a list page on base of that table, add the object no. of the page in table properties LookupPageID,DrillDownPageID.

    in the request page you use a glob. var. e.g. subid. in the req. page line do not set a table relation.
    add following code in the subid - OnLookup trigger:
    IF PAGE.RUNMODAL(0,table50000) = ACTION::lookupok THEN
    subid := table50000.SubjectID + '-' + table50000.Issue;


    ------------------------------
    Franz Kalchmair
    Microsoft MVP
    Senior Consultant
    Vienna, Austria, Europe
    ------------------------------



  • 3.  RE: NAV C/AL Coding Question - Lookup on a Report Request Page

    TOP CONTRIBUTOR
    Posted Mar 12, 2018 10:30 AM
    ​Thank you @Franz Kalchmair!

    That was a great help.




    ------------------------------
    Lewis Rosenberg
    IT Manager
    Mars Fishcare
    Chalfont PA



    NAVUG Board of Advisors, Programming
    NAVUG Programming Committee
    NAVUG Membership Committee
    ------------------------------



  • 4.  RE: NAV C/AL Coding Question - Lookup on a Report Request Page

    TOP CONTRIBUTOR
    Posted Mar 12, 2018 10:42 AM
    When you're looking up on a field, you can only retrieve one value, hence the code workaround.

    Another option, although perhaps not as elegant, would be to add a combination field that takes both values of the key into itself, and that's the field you would look up on (if that makes any sense).

    This is a common trick I use in PowerPivot tables or even Jet Reports sometimes.

    ------------------------------
    Val Gameiro
    Advanced Business Systems, LLC
    Implementer/Project Manager
    Austin, Texas
    former NAVUG Austin Chapter Leader
    ------------------------------



If you've found this thread useful, dive deeper into User Group community content by role