Skip to content
This repository has been archived by the owner on Jun 16, 2024. It is now read-only.

RetrieveEntityDataSource is returning null value #579

Open
ilazarevski opened this issue Oct 10, 2021 · 3 comments
Open

RetrieveEntityDataSource is returning null value #579

ilazarevski opened this issue Oct 10, 2021 · 3 comments

Comments

@ilazarevski
Copy link

Describe the bug
When calling the RetrieveEntityDataSource method from IEntityDataSourceRetrieverService, always is retuning null value, despite the defined "DataSourceId" and "DataProviderId" in the metadata of the virtual entity.

Expected behavior
Entity data source defined for the virtual entity.

** FakeXrmEasy and Dynamics 365 / CRM version **
FakeXrmEasy v9 (1.57.1). Core Assemblies v 9.0.0.7.

Screenshots
image
image

@BetimBeja
Copy link
Contributor

Hello @ilazarevski ,
look at the example test written here:

public void IServiceProvider_should_has_IEntityDataSourceRetrieverService_in_v9()
{
var context = new XrmFakedContext();
context.EntityDataSourceRetriever = new Entity("abc_customdatasource")
{
["abc_crmurl"] = "https://...",
["abc_username"] = "abcd",
["abc_password"] = "1234"
};
var pluginContext = context.GetDefaultPluginContext();
var entity = new Entity();
var query = new QueryExpression();
pluginContext.InputParameters["Query"] = query;
context.ExecutePluginWithConfigurations<RetrieveMultipleDataProvider>(pluginContext, null, null);
var outputParameters = pluginContext.OutputParameters["BusinessEntityCollection"] as EntityCollection;
Assert.Equal(2, outputParameters.Entities.Count);
Assert.Equal("abc_dataprovider", outputParameters.EntityName);
}

I don't think it is a bug, it just has been implemented differently from what you were expecting.

@jordimontana82
Copy link
Owner

jordimontana82 commented Oct 10, 2021

Thanks @ilazarevski @BetimBeja

Indeed, the initialization is as per Betim's answer. I suppose if the community finds it valuable to also initialize the EntityDataSourceRetriever based on metadata . For example, as long as the EntityMetadata has both the DataProviderId and DataSourceId properties?

@ilazarevski
Copy link
Author

ilazarevski commented Oct 10, 2021

@BetimBeja thanks for your answer. I understand that is different implementation, but in our case we are consuming the IEntityDataSourceRetrieverService service.
From the other hand, the service gets metadata of virtual entity and uses DataSourceId property to find used data source entity. If it's configured properly it will retrieve the custom data source entity (that's where you store URL and credentials for your external data service) with all columns.
@jordimontana82 you are right, as long as the both fields DataProviderId and DataSourceId are populated.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants