Skip to main content

Notifications

Announcements

No record found.

Customer experience | Sales, Customer Insights,...
Answered

How to get the Account ID from Contact Ribbon

Posted on by 1,017

Hi,

I have the Contact entity which has the Account lookup. On Contact list view, on click of a custom button- I would like to pass the Account GUID ( All I am trying to do is open the specific account that is linked to the contact)

Please advise the steps and JS on how I can get the Guid of the Account on click of the Ribbon button from Contact?

Thanks.

  • Verified answer
    Bipin D365 Profile Picture
    Bipin D365 28,964 Super User 2024 Season 1 on at
    RE: How to get the Account ID from Contact Ribbon

    HI,

    You can get the contactId from CRM parameters in your JS.

    d365demystified.com/.../

    Now based on ContactId you need to fetch Account lookup value using below code -

    Xrm.WebApi.online.retrieveRecord("contact", "9e4967da-8ee4-eb11-bacb-0022486e98df", "?$select=_accountid_value").then(

    function success(result) {

    console.log(result);

    // Columns

    var contactid = result["contactid"]; // Guid

    var accountid = result["_accountid_value"]; // Lookup

    var accountid_formatted = result["_accountid_value@OData.Community.Display.V1.FormattedValue"];

    var accountid_lookuplogicalname = result["_accountid_value@Microsoft.Dynamics.CRM.lookuplogicalname"];

    },

    function(error) {

    console.log(error.message);

    }

    );

    Please mark my answer verified if this is helpful!

    Regards,

    Bipin Kumar

    Follow my Blog: 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,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans