Skip to main content

Notifications

Announcements

No record found.

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

Issue getting the account's owner contact

Posted on by 55

Hello

I'm able to extract data from CRM using the APIs and having issues obtaining the account's owner contact.

While using the following url (companyname and client name replaced

companyname.crm.dynamics.com/.../accounts eq 'client name'

I'm able to obtain 

,"_ownerid_value":"546f4265-55b9-e411-806b-f0921c195204"

but while trying to use the following url to get the owners data (companyname replaced
https://companyname.crm.dynamics.com/api/data/v9.1/contacts?$select=contactid,firstname,lastname&$filter=contactid eq '546f4265-55b9-e411-806b-f0921c195204'
I get empty result.

Thank you in advance for your support.


  • PabloCRP Profile Picture
    PabloCRP 1,086 on at
    RE: Issue getting the account's owner contact

    Hi, please provide the query you are running which is failing, remember that the example above returns owners contact for selected account.

    e.g. ...accountid eq '42f000f2-2dba-e411-ace1-6c3be5a85de8'

    if you pass a GUID of contact it won't work because it needs an account.

    Regards

  • Enediel Gonzalez Profile Picture
    Enediel Gonzalez 55 on at
    RE: Issue getting the account's owner contact

    Thank Pablo again

    I tried the following based in your suggestion (companyname changed)

    companyname.crm.dynamics.com/.../accounts ne null and accountid eq '42f000f2-2dba-e411-ace1-6c3be5a85de8'

    as answer I got

    ..primarycontactid":{"_ownerid_value":"4af8f02e-452d-e411-a820-6c3be5a85de8","contactid":"db17140a-f169-ea11-a811-000d3a55d2c3"}}]}

    using "contactid":"db17140a-f169-ea11-a811-000d3a55d2c3" I get the primary contact for the account but not the owner of it.

  • PabloCRP Profile Picture
    PabloCRP 1,086 on at
    RE: Issue getting the account's owner contact

    Hi, your ODATA query could be like

    /api/data/v9.0/accounts?$select=name,[HERE CAN PLACE MORE COLUMNS]&$expand=primarycontactid($select=_ownerid_value)&$filter=primarycontactid/contactid ne null and accountid eq [HERE YOUR ACCOUNT ID]

    Regards.

  • Enediel Gonzalez Profile Picture
    Enediel Gonzalez 55 on at
    RE: Issue getting the account's owner contact

    Hello everyone, thank Pablo for your answer but my goal is to find the owner's contact for each account, if you notice I do the first query using the "account" entity, taking the owner_id from there and trying to find it in the "contact" entity returning empty result.

    Is there any relationship diagram between all the entity fields?

    Greetings

  • Suggested answer
    PabloCRP Profile Picture
    PabloCRP 1,086 on at
    RE: Issue getting the account's owner contact

    Hi Enediel Gonzalez,

    there you are filtering by contactid if your need filter by owner should be

    $&filter=_ownerid_value eq '546f4265-55b9-e411-806b-f0921c195204'.

    Regards

    please consider marking as an answer if it was helpful

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,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans