0
votes

In Current Project i am using this syntax to retrieve data from Dynamic CRM:

using (OrganizationServiceProxy serviceProxy = new OrganizationServiceProxy(organizationUri, null, _crmCredentials, null)
{
    // Creating IOrganizationService object to access organization services
    IOrganizationService service = serviceProxy;
    EntityCollection retrieveAccountGuid = service.RetrieveMultiple(QueryOptions);

    return retrieveAccountGuid;
}

Any one please help me what changes i need to do?

I have Read this article but how to replace IOrganizationService in code?

https://docs.microsoft.com/en-us/power-apps/developer/data-platform/authenticate-office365-deprecation

1
Welcome to StackOverflow. When possible, please do not include images of code. Instead just include a code block in your post.Henk van Boeijen

1 Answers

0
votes

The CrmServiceClient is the class we can use to connect to Dynamics 365 in .NET. It supports multiple authentication scenarios. For server-to-server communications on Azure and the Power Platform working with app registrations is the recommended approach.

App registrations accessing Dynamics/Dataverse need to be added as application users and must be assigned an appropriate security role. See also Register an app with Azure Active Directory - MS Docs.

CrmServiceClient implements the IOrganizationService interface, so the majority of your code should work just the same way. Just replace the instantation of the OrganizationServiceProxy by something like this:

private void Test(Uri dataverseUrl, Guid clientId, string clientSecret, string tokenCachePath)
{
    using (var client = new Microsoft.Xrm.Tooling.Connector.CrmServiceClient(dataverseUrl, clientId.ToString("D"), clientSecret, false, tokenCachePath))
    {
        Perform(client);
    }
}

private void Perform(IOrganizationService organizationService)
{

}

CrmServiceClient can be found in NuGet package Microsoft.CrmSdk.XrmTooling.CoreAssembly.