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 CRM (Archived)

How "AccountId" is filled from webapi/soap endpoint perspective on Contact entity ?

(0) ShareShare
ReportReport
Posted on by 2,541

Hello everyone,

I have an interesting point, i can't figure out and need your help.
For a client project, i need to integrate a tool focusing on Contacts and Accounts data.

To load a contact, they use the field "_accountid_value" to link contact record with an account record on their side.

I found out that it's a field defined "only" on the Contact view in the database level and is based on this filtering :
2018_2D00_02_2D00_21_5F00_11_2D00_08_2D00_07_5F00_notepad_2B002B00_.png
Additionnal point i saw, is that as soon as there is a custom field linking the contact entity to account entity, there is an extra LEFT JOIN done in the query but in my example, it's a vanilla environment. 
So far, everything make sense, i got how the field was used from database point of view.
Now my point is : 
  • From the DB perspective, no issue, as soon as i create/update a contact record and associate an account via the "ParentCustomerId" field, the "AccountId" field directly gets the new guid of the Account record as you can see below

2018_2D00_02_2D00_21_5F00_11_2D00_16_2D00_29_5F00_TeamViewer.png

  • From WebApi/Soap endpoint perspective, i have an issue, the result for the same contact record has a null value for the field "_accountid_value", even few hours after the creation.
As you can see below, for the same record value, with the Soap endpoint, the value is "Null" ...
2018_2D00_02_2D00_21_5F00_11_2D00_17_2D00_44_5F00_TeamViewer.png

My final questions are : 
  • How this " _accountid_value" is filled from webapi/soap endpoint point of view? 
  • Is there a background job ? 
  • Is there any "cache" related to webapi queries ?
  • Something else i'm missing ?
Thanks a lot,
Regards,
Clément
PS : today (one/two days later i updated the contact, value is still null)

*This post is locked for comments

I have the same question (0)
  • a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Hello,

    Your images are not available. Can you please update your post?

  • Michel van den Brink Profile Picture
    4,697 on at

    Hello Clément,

    On the Contact entity the field 'accountid' is a virtual field, it doesn't actually exist.
    (Only in the WebApi this field is refered to as '_accountid_value' due to the OData implementation, the actual name of the field is just 'accountid' and yes, it exists in some DB views but, it doesn't exist in a table)

    The field 'parentcustomerid' is a real lookup field and has a little Dynamics 365 specific quirk: you can enter both the ID for an Account, as well as a Contact

    --

    The field 'accountid' is a virtual one, which is supposed to only contain a GUID value when 'parentcustomerid' is set to the GUID of an Account record, otherwise it will be NULL

    Likewise, there is also a virtual field called 'contactid', this one will only contain a GUID value when 'parentcustomerid' is set to the GUID of a Contact record, otherwise it will be NULL.

    --

    To specifically answer your question: The '_accountid_value' field is not filled via background job, nor is there any cache, it is possible that it is NULL because the value for 'parentcustomerid' was NOT set to an Account record. Perhaps the value for 'parentcustomerid' is accidentally set to a a record that doesn't exist?

  • Clem Profile Picture
    2,541 on at

    @Andrew, the pictures are updated (normally).

    @Michel, thanks for your input, i totally agree with you, on the fact that it's virtual field.

    As you can see (if the pics work now) in the query from the DB directly, the parentcustomeridtype = 1, so it's an account for sure, but nothing is coming back from the WebApi query, it remains to "Null" value.

    Clément

  • Verified answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Clement,

    I believe how OData works in D365 it's more question to product team because they own the code.

    Why don't you want to use _parentcustomerid_value field in your OData calls instead of _accountid_value?

  • Verified answer
    Radu Chiribelea Profile Picture
    6,667 on at

    Hi Clement,

    To me, this looks like a bug.

    I've did following test: created a Contact record having the PrimaryCustomerId filled in with an account

    clem2.PNG

    And then I've sent following WebApi Query:

    mycrmserver/.../contacts$select=_accountid_value&$filter=_accountid_value%20ne%20null

    This returned following JSON

    {
        "@odata.context": "crm.crmlab.local/.../v8.2$metadata#contacts(_accountid_value)",
        "value": [{
            "@odata.etag": "W/\"876016\"",
            "_accountid_value": null,
            "contactid": "13c8fdd7-40db-e711-a956-000d3a21a201"
        }]
    }
    However, at the same time I had a CRM Platform trace enabled and noticed that following query was generated against the CRM Platform
    select
    top 5001 "contact0".AccountId as "accountid"
    , convert(bigint, "contact0".VersionNumber) as "versionnumber"
    , "contact0".ContactId as "contactid"
    , "contact0".AccountIdYomiName as "accountidyominame"
    , "contact0".AccountIdName as "accountidname"
    from
     Contact as "contact0"
    where
     (("contact0".AccountId is not null)) order by
     "contact0".ContactId asc
    If I run this directly against the CRM DB in SSMS, this returns
    clem2.PNG
    So the data is retrieved correctly from the DB and associated with the AccountID, however when building the attribute collection, this seems to be left out.
    I suggest reaching out to MS Support and report this behavior.
    Hope this helps!
    Radu
  • Clem Profile Picture
    2,541 on at

    Thanks for your feedbacks,

    I will indeed reach the support.

    @Andrew, that's not my product but one i need to integrate so i don't have to power to change the field used :)

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 CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans