HOW TO MAP LOOKUP FIELDS INTO CURRENT RECORD

As a Dynamics 365 consultant, you absolutely faced the scenario when changing a lookup field on the form, to map fields of the record chosen in the lookup into fields on the main form you are working on.

In this post, I will show you some methods how to map fields from a lookup into the main record fields.

Based on the requirements, you can apply the appropriate approach that is suitable for your need.

  1. JavaScript
    The first approach is to use JavaScript that requires a technical consultant to write the needed functions that will be executed on change event of the lookup field.

    What happens when you apply this approach
    • A retrieve request should be done to get the values from the lookup that will be set on the main form fields
    • The user will directly see the values on the form when changing the lookup field
    • The user will still be able to override the values prefilled from the lookup if they are not read-only
    • No new update request on the record because the values will be saved on the same update request of the form save action

    Map lookup fields in javascript

  2. Plugins
    As per the JavaScript approach, this method requires a technical consultant to write the needed functions that will be executed to fill the needed entity fields.

    What happens when you apply this approach
    • A retrieve request should be done to get the values from the lookup that will be set on the main entity fields
    • The user will still be able to override the values filled from the lookup if they are not read-only
    • When using the PreOperation phase, no new update request on the record is needed, because the values will be added to the entity context and saved at the same create/update request of the entity create/save action.
      In this case, the user will directly see the values reflected on the form when the plugin is completed
    • When using the PostOperation phase or Asynchronous mode, a new update request should be done to save the values in the database and the user must wait some time and refresh the form in order to see the values reflected on the form

    Map lookup fields in plugins

  3. Workflow
    Using a workflow do not require a technical consultant, a functional person can create a workflow that will be executed when the lookup is filled and will set the needed fields on the form by the ones from the lookup.

    What happens when you apply this approach
    • No retrieve request is done to get the values from the lookup
    • A new update request should be done (update step) to save the lookup values on the form
    • The user will still be able to override the values filled from the lookup if they are not read-only
    • When using a synchronous workflow, the values will be directly reflected on the form when the workflow is completed
    • When using an asynchronous workflow, the user must wait some time and refresh the form in order to see the values reflected on the form

    Map lookup fields in workflow

  4. Calculated Fields
    Using Calculated Fields does not require a technical consultant, a functional person can create the calculated fields and pointing to the appropariate field of the lookup in the action section.

    What happens when you apply this approach
    • No retrieve request is done to get the values from the lookup
    • No new update request on the record is done because the values will be saved at the same request of the form action
    • The user will see the values of the lookup on the form after saving the form
    • The user will not be able to override the values filled from the lookup because calculated fields are read-only

    Map lookup fields in calculated fields

  5. Power Automate
    Using Power Automate does not require a technical consultant, a functional person can create the flow that will be executed and will set the needed fields on the form by the ones from the lookup.

    What happens when you apply this approach
    • A retrieve request should be done to get the values from the lookup that will be set on the main entity fields
    • A new update request should be done to save the lookup values of the record
    • The user must wait some time and refresh the form in order to see the values reflected on the form
    • The user will still be able to override the values filled from the lookup if they are not read-only

    Map lookup fields in power automate

  6. 1:N Relationship Mappings
    This approach can be done by a functional person as well on the level of the 1:N relationship where the needed fields can be selected to be mapped from the parent record and will set the needed fields on the form by the ones from the parent lookup.

    What happens when you apply this approach
    • Mapping of the fields will be applied only when creating a record from the sub-grid
    • The user will directly see the values on the form when the create form opens
    • No retrieve request is done to get the values from the parent lookup
    • No new update request on the record is done because the values will be saved at the same request of the form action
    • The user will still be able to override the values filled from the lookup if they are not read-only

    Map lookup fields in mappings

Hope This Helps!

Comments

Popular posts from this blog

DYNAMICS 365 HOW TO HIDE RECENT RECORDS FOR LOOKUP FIELD IN UCI

SEARCH BY GUID IN DYNAMICS 365

SAVE FORM IN DYNAMICS 365 JAVASCRIPT