Custom bi-directional Microsoft Dynamics 365 Integration for Lookup Tables: a practical example.

It could be considered quite a typical request to integrate a custom supplemental table (Dynamics 365 for Sales Lookup table) in Dynamics NAV when dealing with integration projects. The scope of this blog post is to provide a general guidance at high-level which are the tasks to accomplish to be successful in achieve this goal.

Attached at the end of the post, you’ll find a full object sample, based on Microsoft Dynamics NAV Cronus IT Cumulative Update 16.

Generic Inquiry:

  • Request the capability of categorizing each Dynamics NAV Customer and/or Dynamics 365 Account per a defined custom Group Segment
  • Dynamics NAV Customer and/or Dynamics 365 for Sales must be synchronized either manually or automagically
  • Group Segment could be created either with Dynamics NAV or Dynamics 365 for Sales
  • Group Segment must be synchronized either manually or automagically

Development tasks:

  1. Create a custom Microsoft Dynamics 365 for Sales Solution that contains:
    1. New custom entity: Group Segment

      With the following fields

      (see below a typical view)

    2. Lookup to Group Segment in the Account entity (the one selected below)
  2. Create a Dynamics NAV supplemental table: Group Segment
    1. Create a Group Segment Card and List bounded to it
    2. Change Customer Table to add the relevant Group Segment Code and Description
    3. Change Customer List and Card for display and data entries
  3. Use the New-NAVCrmTable PowerShell cmdlet to:
    1. Regenerate CRM Account table
    2. Generate CRM Group Segment table
      NOTE: Both tables must be added in the same PowerShell command to respect the dependencies between the two tables and extract the appropriate lookup fields
  4. Import the CRM Group Segment table.
    Below how it should look like with highlighted the relevant fields.
  5. Export CRM Account table in TXT format, merge only the new fields needed for Group Segment display and handling. Import back and compile them.
    Below a snippet of the lookup field just added:And their properties:
  6. Create a CRM Group Segment List in Dynamics NAV bounded to the CRM Group Segment table.
  7. Modify the relevant Microsoft Dynamics NAV objects to orchestrate the following
    1. Add Group Segment as valid Integration Record for Dynamics 365 for Sales Integration
      Change Codeunit 5150 “Integration Record
    2. For a typical manual synchronization within a card page, change Codeunit 5330 “CRM Integration Management”
    3. Handle the lookup to the CRMTable by changing Codeunit 5332 “Lookup CRM Tables” function Lookup and creating a brand new one: LookupCRMGroupSegment
    4. Set up Defaults to automate the creation of Table/Field mappings and Job Queue automagic enablement. Change the following functions in Codeunit 5334 “CRM Setup Defaults” and create a new one: RestGroupSegmentMappingThis step would help in generate the relevant Integration MapAnd their corresponding Field mappings
    5. And now, the last but most IMPORTANT step to understand.
      Since the lookup field is handled through a GUID relation within the Dynamics 365 for Sales entity and a Code field in Dynamics NAV, this bidirectional dichotomy has to be handled through a very specific event when transferring Customer / Account fields back and forth.
      More in deep, the relevant event is OnAfterTransferRecordFields in Codeunit 5341 “CRM Int. Table. Subscriber” for whom we need to add some code and 2 functions to handle lookup updates in both systems

In the end, you will see that Dynamics NAV and Dynamics 365 for Sales group segments can be integrated bi-directionally and also Lookup / FlowField added in the Account / Customer is flowing back and forth beautifully.

Remember: a mantra for system integrators reads :“All integrations are never so simple as they seem”.

Download: GroupSegment.POC.txt


These postings are provided “AS IS” with no warranties and confer no rights. You assume all risk for your use.
Duilio Tacconi (dtacconi)
Microsoft Dynamics Italy
Microsoft Customer Service and Support (CSS) EMEA