Tuesday, April 14, 2015

Dynamics NAV 2015 - How to create a Lookup, Dropdown, or option list

Situation:
Trying to create Lookup field on one Page that uses data from another Table to populate a field in the current table.

Solution:
This example - Creating a customer lookup on an invoice

  • Create Customer Table with CustomerID
  • Create Field for CustomerID on Invoice Header Table

  • On Invoice Header Page
    • Add CustomerID to Page
    • Set SourceExpr to point to the table you want to use as the lookup
    • Set TableRelation to the table/field you want to lookup on
      • In the table, set the DropDown list under View>Field Groups 
      • Name: DropDown, Group>three dots>Select fields you want in lookup
    • If you want advanced lookup options
      • Under Properties for the CustomerID field
        • Lookup = Yes
        • LookupPageID = Customer
More tips on customizing the dropdown here

To Create a Custom Drop Down list
  • On the Table, set the datatype to Option
  • Fill in the OptionString Field with your options lit separated by commas
  • If you want separate descriptions, Fill in the OptionCaption field on the Properties of the field on the page
    • example <Wedding,Baby Shower,Bridal Shower,Anniversary,Birthday,Grad,Home,Other>
To Create a Custom Drop Down list from a global Variable as an Input on the Request Page
  • Create Global Variable - Type Option
    • Enter all option values
  • On request page, insert global variable
  • On Report page, insert global variable so it can be seen by the report
  • Use SSRS or CAL Logic to reference the field
To create a dropdown field on a report request page 
  • Go to the table where the field is being taken from
  • Set the TableRelation to the table you want to get your dropdown values from
    • On the Table you're getting the dropdown values from, Design>View>Field Groups
    • Create a field group named "DropDown" and select the columns you want to display
    • Whenever this table is used as a related dropdown, it will use the DropDown field group settings

To create a completely custom lookup, use the Onlookup trigger on the table.
This logic will replace the default lookup.

No comments:

Post a Comment