web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Answered

All accountids for contacts are null when retrieving them in Azure Data Factory (copy activity)

(3) ShareShare
ReportReport
Posted on by 29
[Originally asked here: https://learn.microsoft.com/en-us/answers/questions/2260524/dynamics-crm-all-accountids-for-contacts-are-null - but the moderators suggested I move the question here]
 
We want to retrieve all contacts (and other entities) from MS Dynamics CRM every night, to process them to our data store. We've successfully set up the methodology that is described here: https://learn.microsoft.com/en-us/azure/data-factory/connector-dynamics-crm-office-365?tabs=data-factory.
A Service principal / enterprise application was setup that (at the least) has access to the data (as described somewhat unhelpfully in https://learn.microsoft.com/en-us/power-apps/developer/data-platform/reference/entities/contact) this way.
 
However, when we fetch all contacts, there is no data in the accountid field (note: in the Dynamics CRM UI, and to the best of my knowledge, all contacts are associated with an account). Or rather:
  • when using the method just specifying the source entity, all accountid-related fields are null for all records (~130000)
  • when using fetchxml instead and just specifying the attributes of interest, all accountid-related fields are null for all records (~130000)
  • when using fetchxml but specifying the link-entity without a link type, suddenly we only get ~180 records that DO have a valid accountid (!!!) but now the other records are no longer returned. The fetchxml I used is at the bottom of this post
  • when using fetchxml similarly as above, but adding link-type="outer" to the link-entity, again, all records are returned, but NONE have a valid accountid (all are NULL)
The sum of the above suggests:
  • the account I am using has the correct permissions (otherwise the second bullet would not return valid accountids)
  • there is something (unclear which of the involved technologies) that "optimizes away" even the valid accountids when "most of them" (likely: the first X records?) are null
  • there must be some other "magical" way that contacts are "related" to an account, that is: not through their own accountid-attribute. Either that or the API used here is fundamentally flawed
  • we are not the only ones seeing this faulty behavior
I'm seriously thinking this is a bug (or a stack of bugs), but I'm hoping someone here might still have a viable suggestion?
Are there, perhaps other/better ways of retrieving "all" the data from CRM?
 
 
Thanks for any input
 
 
As said: the fetchxml (incidentally: does anyone have proper documentation on this?) I used:
<fetch>
  <entity name="contact">
    <attribute name="contactid" />
    <attribute name="accountid" />
    <link-entity name="account" from="accountid" to="accountid" alias="acc">
      <attribute name="accountid" alias="linkaccountid"/>
    </link-entity>
    <attribute name="fullname" />
  </entity>
</fetch>
 
 
I have the same question (0)
  • Verified answer
    NickSabbe Profile Picture
    29 on at
    I more or less have to answer my own question.
    Apparently, our implementing partner for Dynamics CRM decided to use a new (?) field (called ahs_accountid) for maintaining the relationship between the contact and the account, which explains why the "original" field (accountid) is null everywhere.
    There are still a few strange things about this, but they are not in my own way anymore.
    * when using fetchxml with no attributes specified, the field ahs_accountid is returned (among many others)
    * when doing the same and explicitly specifying ahs_accountid as an attribute, it is NOT returned (while others also explicitly specified are)!
    To me, this still points to some inherent problems behind the scenes (read: a bug) that led me on a false path.
    For now I am happy to always include all attributes, but that may change in the future.
    I'm mostly leaving this here for people struggling with similar issues.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
iampranjal Profile Picture

iampranjal 51

#2
Martin Dráb Profile Picture

Martin Dráb 39 Most Valuable Professional

#3
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 26 Super User 2025 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans