locked
Retrieve Organization Unique Name from MSCRM database RRS feed

  • Question

  • I built a link from SSR report to a open a CRM record. For example once I click on on accountid on the ssrs report it will open that particular account in CRM.

    I need to build the url to CRM to Retrieve Organziation unique name dynamically from the server.

    I wonder if any body can hep me to get the Organization name and server name using a filter view if possible?

    I already did some investigation I got the following result.

    1- I Used the below query but it just returns me the display name of the Organization While I need unique Name of the organization 

    SELECT NAME
      FROM FilteredOrganization   -> Returns the display name instead of unique name

    2-I also tried

    SELECT       UniqueName]
      FROM [MSCRM_CONFIG].[dbo].[Organization]  -> But this is not a good choice as in crm 2011 it returns multiple row as we can have multiple organizations

    So I wonder if there is any way to use a filter view or some how retrieve the unique organization name?

    Any idea would be much appreciated!

    Maryam

    Tuesday, October 1, 2013 11:18 PM

Answers

  • Hi,

    You can get Unique name of your organization by using this:

    SELECT       [UniqueName]
      FROM [MSCRM_CONFIG].[dbo].[Organization] Where FriendlyName = ['Your Tenant Friendly Name']


    If this post answers your question, please click "Mark As Answer" on the post and "Mark as Helpful" Thanks, Imran Abbasi

    • Proposed as answer by Imran I Abbasi Tuesday, October 1, 2013 11:43 PM
    • Marked as answer by Maryam_r Wednesday, October 2, 2013 3:00 PM
    Tuesday, October 1, 2013 11:43 PM

All replies

  • Hi,

    You can get Unique name of your organization by using this:

    SELECT       [UniqueName]
      FROM [MSCRM_CONFIG].[dbo].[Organization] Where FriendlyName = ['Your Tenant Friendly Name']


    If this post answers your question, please click "Mark As Answer" on the post and "Mark as Helpful" Thanks, Imran Abbasi

    • Proposed as answer by Imran I Abbasi Tuesday, October 1, 2013 11:43 PM
    • Marked as answer by Maryam_r Wednesday, October 2, 2013 3:00 PM
    Tuesday, October 1, 2013 11:43 PM
  • Hi Imran,

    Thanks for the reply. Your answer gave me a hint how I can do it.

    Below is how I retrieve the Organization name dynamically without hard coding the Friendly name, In case some one need it.

    DECLARE @CRMUrl nvarchar(255) 
    DECLARE @FrienlyOrgName nvarchar(100) 
    DECLARE @OrgName nvarchar(100) 

    --Retrieve Server Name
    SELECT @CRMUrl = 'http://' + Name + '/'
     FROM [MSCRM_CONFIG].[dbo].[Server]
    WHERE Name NOT IN
         (SELECT [name]
     FROM [MSCRM_CONFIG].[sys].[servers])

    Select @FrienlyOrgName = name from dbo.FilteredOrganization

    --RetrieveOrganization Name
    SELECT 
    @OrgName = UniqueName
    FROM [MSCRM_CONFIG].[dbo].[Organization] where friendlyname = @FrienlyOrgName

    select @CRMUrl + @OrgName 

    Wednesday, October 2, 2013 3:02 PM