Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics 365 | Integration, Dataverse...
Suggested answer

Problem populating a multi target lookup field in D365 (ownerid) from Azure Data Factory

Posted on by 20

Hi,

I am trying to import data from a CSV file into a Dynamics 365 Account table. As I need to do some transformations I am using a dataflow rather than a basic copy activity.

I was having difficulties getting it to work using a dataflow for writing to a multi lookup field so I tried using a copy activity to see if that worked using the exact same source,sink and mappings. I was able to import the data successfully with the copy activity. I'm confused as to why the data flow does not work using the same source,sink and mappings. Below are screenshots of the various elements I set up and configured. Would appreciate any suggestions to get the dataflow working.

I'm using a cut down version of what will ultimately be my source CSV file. This is just so I can concentrate on getting the writing to the lookup field working.

Source CSV file

pastedimage1654808081154v1.png

Copy Activity Source

pastedimage1654808081156v2.png

Copy Activity Sink

pastedimage1654808081157v3.png

Dynamics 365 Sink

pastedimage1654808081159v4.png

Dataflow Source

pastedimage1654808081160v5.png

Dataflow Sink

pastedimage1654808081161v6.png

Copy Activity Mapping

pastedimage1654808081162v7.png

Dataflow Mapping

pastedimage1654808081163v8.png

Copy Activity Success

pastedimage1654808081163v9.png

Dataflow Failure

pastedimage1654808081164v10.png

Dataflow Error

pastedimage1654808081165v11.png

Details {"StatusCode":"DFExecutorUserError","Message":"Job failed due to reason: DF-REST_001 - Rest - Error response received from the server (url:https://##############v9.0/accounts,request body: Some({"accountid":"8b0257ea-de19-4aaa-9945-############","name":"A User","ownerid":"7d64133b-daa8-eb11-9442-############","ownerid@EntityReference":"systemuser"}), request method: POST, status code: 400), response body: Some({"error":{"code":"0x0","message":"An error occurred while validating input parameters: Microsoft.OData.ODataException: A 'PrimitiveValue' node with non-null value was found when trying to read the value of the property 'ownerid'; however, a 'StartArray' node, a 'StartObject' node, or a 'PrimitiveValue' node with null value was expected.\r\n at Microsoft.OData.JsonLight.ODataJsonLightPropertyAndValueDeserializer.ValidateExpandedNestedResourceInfoPropertyValue(IJsonReader jsonReader, Nullable1 isCollection, String propertyName, IEdmTypeReference typeReference)\r\n at Microsoft.OData.JsonLight.ODataJsonLightResourceDeserializ","Details":"com.microsoft.dataflow.Issues: DF-REST_001 - Rest - Error response received from the server (url:https://dev-gc.crm11.dynamics.com/api/data/v9.0/accounts,request body: Some({"accountid":"8b0257ea-de19-4aaa-9945-############","name":"A User","ownerid":"7d64133b-daa8-eb11-9442-############","ownerid@EntityReference":"systemuser"}), request method: POST, status code: 400), response body: Some({"error":{"code":"0x0","message":"An error occurred while validating input parameters: Microsoft.OData.ODataException: A 'PrimitiveValue' node with non-null value was found when trying to read the value of the property 'ownerid'; however, a 'StartArray' node, a 'StartObject' node, or a 'PrimitiveValue' node with null value was expected.\r\n at Microsoft.OData.JsonLight.ODataJsonLightPropertyAndValueDeserializer.ValidateExpandedNestedResourceInfoPropertyValue(IJsonReader jsonReader, Nullable1 isCollection, String propertyName, IEdmTypeReference typeReference)\r\n at Microsoft.OData.JsonLight.ODataJsonLightResourceDeser"}

  • Jorge Moreno B Profile Picture
    Jorge Moreno B 15 on at
    RE: Problem populating a multi target lookup field in D365 (ownerid) from Azure Data Factory

    If there are two entities related(Entity A has lookup pointing to Entity B), and both have no records in CRM, then what I would do is to load Entity B first, then Follow Steps 1->7  in a different pipeline. Where Datasource1 is equal to Entity A.

  • PrateekV Profile Picture
    PrateekV 10 on at
    RE: Problem populating a multi target lookup field in D365 (ownerid) from Azure Data Factory

    Hello thanks for your response.

    Since these are new records there is no GUID present already in dynamics.

    Are you saying first load data for the entity without selecting lookup entity related fields. Then after load is done follow your step 2 to step 7 to load data into the lookup entity now.

    Is there a way to directly load the data into the lookup entity from the source data via adf and without having to create GUIDs.

  • Jorge Moreno B Profile Picture
    Jorge Moreno B 15 on at
    RE: Problem populating a multi target lookup field in D365 (ownerid) from Azure Data Factory

    No, you must translate it to a GUID.

    1. Create Data Flow
    2. DataSource1 your file
    3. DataSource2 Query CRM Entity so you can transform text to guid
    4. Use Join to get Guid column
    5. I use select to have the target file columns match CRM fields logical names
    6. Sink the results to a CSV file
    7. Then use Copy Data Activity to Sink the new file to CRM Dynamics

    That is the way I am doing it right now.

  • PrateekV Profile Picture
    PrateekV 10 on at
    RE: Problem populating a multi target lookup field in D365 (ownerid) from Azure Data Factory

    Hi All, can I do the same using copy activity even when I do not have the ID column for the lookup entity available in my source data.

  • Jorge Moreno B Profile Picture
    Jorge Moreno B 15 on at
    RE: Problem populating a multi target lookup field in D365 (ownerid) from Azure Data Factory

    Does any of you figure out a way to map the lookup from the DataFlow directly to CRM Sink?

  • Suggested answer
    PeterGa Profile Picture
    PeterGa 5 on at
    RE: Problem populating a multi target lookup field in D365 (ownerid) from Azure Data Factory

    Hi Rob, I was just able to fix this using Dataflow to sink transformation into Json file and next action was to take the file as source and sink it to the Dataverse.

    As I had the same issue as you and Andrew mentioned, in Dataflow it does not work, in Pipeline with Copy Activity and correctly prepared file, it works correctly and Im able to set the lookup fields.

    Did you find maybe another working model for Dataflow, to skip the Copy Activity?

  • Rob Dawson Profile Picture
    Rob Dawson 190 on at
    RE: Problem populating a multi target lookup field in D365 (ownerid) from Azure Data Factory

    Hey Andrew. Did you find a resolution to this, or work around? Like you I can get the Copy Activity to work at the pipeline level but this method doesn't work at the Dataflow level. Docs are poor in this regard.

  • AndrewMacInnes Profile Picture
    AndrewMacInnes 20 on at
    RE: Problem populating a multi target lookup field in D365 (ownerid) from Azure Data Factory

    Hi Bipin,

    Thank you for the reply. As I have put in my question, I use exactly the technique you have suggested and it works when using a copy activity. However if I try doing it from a dataflow it doesn't work and I get the error I documented in my question above.

    Any idea how to get it to work from a dataflow?

    Kind Regards

    Andrew

  • Suggested answer
    Bipin D365 Profile Picture
    Bipin D365 28,964 Super User 2024 Season 1 on at
    RE: Problem populating a multi target lookup field in D365 (ownerid) from Azure Data Factory

    Hi,

    Please see below article to set multi lookup field from ADF

    docs.microsoft.com/.../connector-dynamics-crm-office-365

    xrmdynamicscrm.wordpress.com/.../

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans