I'm using the Dynamics connector in Azure Data Factory.
TLDR
Does this connector support loading child records which need a parent record key passed in? For example if I want to create a contact and attach it to a parent account, I upsert a record with a null contactid, a valid parentcustomerid GUID and set parentcustomeridtype to 1 (or 2) but I get an error.
Long Story
I'm successfully connecting to Dynamics 365 and extracting data (for example, the lead table) into a SQL Server table
To test that I can transfer data the other way, I am simply loading the data back from the lead table into the lead entity in Dynamics.
I'm getting this error:
Failure happened on 'Sink' side. ErrorCode=DynamicsMissingTargetForMultiTargetLookupField,'Type=Microsoft.DataTransfer.Common.Shared.HybridDeliveryException,Message=,Source=,''Type=Microsoft.DataTransfer.Common.Shared.HybridDeliveryException,Message=Cannot find the target column for multi-target lookup field: 'ownerid'.
As a test I removed ownerid from the list of source columns it loads OK.
This is obviously a foreign key value.
It raises two questions for me:
Specifically with regards to the error message: If I knew which lookup it needed to use, how can I specify which lookup table it should validate against? There's no settings in the ADF connector to allow me to do this.
This is obviously a foreign key value. If I only had the name (or business key) for this row, how can I easily lookup the foreign key value?
How is this normally done through other API's, i.e. the web API?
Is there an XRMToolbox addin that would help clarify?
I've also read some posts that imply that you can send pre-connected data in an XML document so perhaps that would help also.
EDIT 1
I realised that the lead.ownertypeid field in my source dataset is NULL (that's what was exported). It's also NULL if I browse it in various Xrmtoolbox tools. I tried hard coding it to systemuser (which is what it actually is in the owner table against the actual owner record) but I still get the same error.
I also notice there's a record with the same PK value in systemuser table
So the same record is in two tables, but how do I tell the dynamics connector which one to use? and why does it even care?
EDIT 2
I was getting a similar message for msauto_testdrive for customerid.
I excluded all records with customerid=null, and got the same error.
EDIT 2
This link appears to indicate that I need to set customeridtype to 1 (Account) or 2 (Contact). I did so, but still got the same error.
Also I believe I have the same issue as this guy.
Maybe the ADF connector suffers from the same problem.
At the time of writing, #Arun Vinoth was 100% correct. However shortly afterwards there was a documentation update (in response to a GitHub I raised) that explained how to do it.
I'll document how I did it here.
To populate a contact with against a parent account, you need the parent accounts GUID. Then you prepare a dataset like this:
SELECT
-- a NULL contactid means this is a new record
CAST(NULL as uniqueidentifier) as contactid,
-- the GUID of the parent account
CAST('A7070AE2-D7A6-EA11-A812-000D3A79983B' as uniqueidentifier) parentcustomerid,
-- customer id is an account
'account' [parentcustomerid#EntityReference],
'Joe' as firstname,
'Bloggs' lastname,
Now you can apply the normal automapping approach in ADF.
Now you can select from this dataset and load into contact. You can apply the usual automapping approach, this is: create datasets without schemas. Perform a copy activity without mapping columns
This is the ADF limitation with respect to CDS polymorphic lookups like Customer and Owner. Upvote this ADF idea
Workaround is to use two temporary source lookup fields (owner team and user in case of owner, account and contact in case of customer) and with parallel branch in a MS Flow to solve this issue. Read more, also you can download the Flow sample to use.
First, create two temporary lookup fields on the entity that you wish to import Customer lookup data into it, to both the Account and Contact entities respectively
Within your ADF pipeline flow, you will then need to map the GUID values for your Account and Contact fields to the respective lookup fields created above. The simplest way of doing this is to have two separate columns within your source dataset – one containing Account GUID’s to map and the other, Contact.
Then, finally, you can put together a Microsoft Flow that then performs the appropriate mapping from the temporary fields to the Customer lookup field. First, define the trigger point for when your affected Entity record is created (in this case, Contact) and add on some parallel branches to check for values in either of these two temporary lookup fields
Then, if either of these conditions is hit, set up an Update record task to perform a single field update, as indicated below if the ADF Account Lookup field has data within it
I have an error log file that contains a GUID of an Entity in Microsoft Dynamics CRM 365 Online, but I do not know the Entity's object type. Is there a way of using FetchXML (or otherwise) to retrieve any Entity with the matching GUID regardless of object type?
A possibility is to retrieve the metadata of all entities (using the RetrieveAllEntitiesRequest message) and after to an IOrganizationService.Retrieve to check if the record exits or not.
You can find a complete example in this blog post:
Retrieve Entity Logical Name from a record GUID
No. Unfortunately, we should always pass the target entity name for the fetchxml or any query in CRM.
But if you're looking for a way to get the entity name (followup to your other question), when you have the GUID in message block/exception details - you can get the "Primary Entity" from the same plugin trace log record as well.
Read more
I am developing a model driven Power App. I have an entity with a few person/group fields like "Updated By" and "Completed By". Is there a way for the App to recognize who is updating a record so that I can place that card into an MS Flow and send an email with the information of who updated the record? Or maybe fill out a field in the record itself of who last edited it?
Model driven Power App (aka Dynamics 365 CRM) stores the last modified person & timestamp by Out-of-the-box design in the modified record itself. You can use that in MS Flow - Dynamic content while sending out an email.
If you want to capture it in some additional field - you can do that also.
I have flatfile source and dynamics crm destination.I have to delete a record from CRM based on Title(text), Startdate(text) and userid(lookup field in CRM) which is given as input from flatfile.Can you suggest how can I achieve this.
Thanks
You can take a look at our Premium Lookup component in the SSIS Productivity Pack, which allows you to perform a lookup against your CRM source. The Premium Lookup component takes two inputs - Primary Input and Lookup Table Input. In your case, you can specify the flat file source component as your Primary Input and use CRM Source component as the Lookup Table Input. With that being done, you should be able to get the corresponded records in the Matched Rows ouput, which can be used to pushed to the CRM Destination component and perform a Delete action. Hope this helps.
Is there a way to retrieve all of the records for a given entity using the Microsoft Dynamics CRM 4.0 SDK? I want the equivalent of:
SELECT foo
FROM new_bar
... where new_bar is the name of the entity.
This seems trivial, but I can't find any examples on how to retrieve all of the records for a given entity.
Because you want to retrieve all the records for a given entity, you need to used the Paging Cookie, otherwise you will get maximum 5000 records.
You can find an example here:
http://msdn.microsoft.com/en-us/library/cc151070.aspx