Thursday, December 1, 2011

CRM 2011 - Retrieving Organization Information

There are many ways to retrieving Organization-Information in code. Some of them are explained in this post.
  • Javascript
  • Organization-Webservice
  • Discovery-Webservice 
  • ...
1.) Javascript (Only Unique-Name)
The XRM-Context offers the a function for retrieving the org unique name.

 This function can be used in Javascript/HTML- and Silverlight-Webresources.

2.) Organization-Webservice (Only Display-Name)
The SOAP-Endpoint of the CRM-System (http://crm:5555/XRMServices/2011/Discovery.svc) offers the default request-functionality for the "organization" entity. The record contains the field "name" which holds the display-name.

Important: If the system is created with import organization and the display-name has been changed in this process, the name in the organization-table of the _MSCRM Database is NOT changed. It still contains the name, selected generating the organization the first time.

3.) Discovery-Webservice (Display & Unique)

The discovery-endpoint also contains a functionality to retrieve organization data. This can be achieved by using the RetrieveOrganizationRequest.

Two remarks if you are using this approach:
  • There is no documentation available, how you can use discovery-endpoint in Silverlight-Webresources
  • The code will not run in offline-mode (SDK: This message works only when connected to the server.)
Update November 2012: The RetrieveOrganizationRequest is not working correctly in online systems for this purposes. Thanks to Mitch Milam.