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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Accessing the Discovery Service from within a plug-in on CRM Online

(0) ShareShare
ReportReport
Posted on by

Hello,

I'm having some problems creating an URL for the entites forms on CRM Online. I have the following function for the URL construction:

public String ConstructUrl(String organizationName, String entityName, String recordId)
{
 String url = "";
 if (!organizationName.Equals("") && !entityName.Equals("") && !recordId.Equals(""))
 {
  url = "https://" + organizationName + ".crm4.dynamics.com/main.aspx?pagetype=entityrecord&etn=" + entityName + "&id=" + recordId;
 }
 return url;
}

The problem is the organizationName, this is not the Organization Unique name , nor the Organization Name which can be found under the User name on the top right corner. I think i need to access the discovery service from within the plugin to get this name but I cannot. I'm trying with the folloing code:

RetrieveOrganizationRequest

orgRequest =
new RetrieveOrganizationRequest()
{
 UniqueName = context.OrganizationName,
 AccessType = EndpointAccessType.Default,
 Release = OrganizationRelease.Current
};

IDiscoveryService discoveryService = (IDiscoveryService)serviceProvider.GetService(typeof(IDiscoveryService));
RetrieveOrganizationResponse org = (RetrieveOrganizationResponse)discoveryService.Execute(orgRequest);
orgName = org.Detail.UrlName;

Can someone tell me what am I doing wrong?
The main question is: How can I get the Organization.UrlName in a Sandbox plugin?

Thanks in advance.
Zoran

*This post is locked for comments

I have the same question (0)

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans