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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested Answer

How to retrieve GUID of record from URl through js code

(0) ShareShare
ReportReport
Posted on by 351

Hello

 when i open my webresource on click of button then I want to retrieve GUID of record from URL through js code..

Thanks & Regards

I have the same question (0)
  • Suggested answer
    ajyendra Profile Picture
    1,738 on at
  • Yash Trivedi CRM Profile Picture
    351 on at

    Hello Ajayendra I got it through this:

    window.top.opener.frames[0].Xrm.Page.data.entity.getId();

    for CRM above 2016 version :

  • Suggested answer
    ajyendra Profile Picture
    1,738 on at

    I think It might not work in Microsoft Edge Browser .

  • Suggested answer
    Naveen Ganeshe Profile Picture
    3,397 User Group Leader on at

    Hello Yash,

    You can use below code snippet to get the ID from URL:

     

    const entityId = getUrlVars()["id"].replace('{', '').replace('}', '');
    
    function getUrlVars() {
        var vars = [], hash;
        var hashes = window.location.href.slice(window.location.href.indexOf('?')   1).split('&');
        for (var i = 0; i < hashes.length; i  ) {
            hash = hashes[i].split('=');
            vars.push(hash[0]);
            vars[hash[0]] = hash[1];
        }
        return vars;
    }

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
ManoVerse Profile Picture

ManoVerse 85 Super User 2026 Season 1

#2
Muhammad Shahzad Shafique Profile Picture

Muhammad Shahzad Sh... 69 Most Valuable Professional

#3
11manish Profile Picture

11manish 64

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans