Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Retrieving entity name using GUID value in SQL Server

Posted on by 210

Hello. I am administering a CRM 4.0 system. I have been running a number of SQL queries in SQL Server on the <my_org>_MSCRM database. The case (incident) entity has a lookup field which is linked to a custom entity called Town. There are a number of case records that have been created by end users with the Town field filled in. Using SQL queries on the CRM database server, I have been trying to retrieve the Town value (as it would appear in the end user's case when opened in CRM). The closest I have got is retrieving the GUID values for the Town field using IncidentExtensionBase.new_townid. I could not find a field which gives the Town name. Using an SQL query how could one retrieve the Town name? 

*This post is locked for comments

  • Rajesh Chungath Profile Picture
    Rajesh Chungath 465 on at
    RE: Retrieving entity name using GUID value in SQL Server

    Please query on FilteredTown view based on townid

  • Suggested answer
    RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: Retrieving entity name using GUID value in SQL Server

    Each lookup is tied up with an entity and each entity has its won table. So you need to find the table for Town entity and then select the name from that table by passing the town id.

  • Verified answer
    Flydancer Profile Picture
    Flydancer 1,332 on at
    RE: Retrieving entity name using GUID value in SQL Server

    Hi synthesis,

    you should have a look at the "FilteredIncident" View. There should be a field like new_townidname.

    Here is a good read about filtered views: community.dynamics.com/.../crm-2015-why-filtered-views-are-useful

    Otherwise you could use the townid to join on the new_townbase table in your query if you want the "raw" data.

  • Suggested answer
    gdas Profile Picture
    gdas 50,085 on at
    RE: Retrieving entity name using GUID value in SQL Server

    Hi ,

    Are you getting any error ? If you  try to retrieve directly data from Town entity , did you get the data?

    Try to retrieve from town and in the Town entity you will find incident id by which you will get the the IncidentExtensionBase data. So just do reverse process .

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

Featured topics

Product updates

Dynamics 365 release plans