在一个CRM on-prem环境中,有多个组织。我已将DiscoveryService URL和组织名称存储在一个配置文件中。
我想使用配置文件中可用的组织名称来获取特定组织的组织实例,而不是加载所有组织。
类似于
select organizations from Organizations where orgName = 'XYZ'
目前,我使用下面的代码,检索一个实例需要3秒以上的时间。
private OrganizationDetail DiscoverOrganization(Uri discoveryUri, string organizationName, ClientCredentials lclClientCredentials)
{
DiscoveryServiceProxy serviceProxy;
using (serviceProxy = new DiscoveryServiceProxy(discoveryUri, null, lclClientCredentials, null))
{
IDiscoveryService service = serviceProxy;
var orgsRequest = new RetrieveOrganizationsRequest() { AccessType = EndpointAccessType.Default, Release = OrganizationRelease.Current };
var organizations = (RetrieveOrganizationsResponse)service.Execute(orgsRequest);
return organizations.Details.FirstOrDefault(x => x.UniqueName.ToLower() == organizationName.ToLower());
}
}
你可以尝试Web api版本。阅读更多
GET https://dev.{servername}/api/discovery/v9.0/Instances(UniqueName='myorg')