Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM forum
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,962 Moderator 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

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,558 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,647 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans