Open BineG opened 5 months ago
Hi @BineG , is the expand you are doing related to a many-to-one (lookup) relationship? To be honest I need to check if a standard relationship has the behavior you described because I quickly checked the code and for many-to-one looks like I am using the ReferencedEntityNavigationPropertyName (but as I wrote I just did a quick check, so I may be wrong)
Hi. It is a one-to-many relationship (I also updated the original post). I'm using version 10.0.0.43 if it makes any difference.
The correct query is /dcntrcrm_reportdefinitions?$select=dcntrcrm_reportdefinitionid,dcntrcrm_reportname&$expand=dcntrcrm_documenttemplate_reportdefinition($select=dcntrcrm_documenttemplateid,dcntrcrm_reporttemplatename)
but DRB generated it as dcntrcrm_reportdefinitions?$select=dcntrcrm_reportdefinitionid,dcntrcrm_reportname&$expand=dcntrcrm_reporttemplate_reportdefinition($select=dcntrcrm_documenttemplateid,dcntrcrm_reporttemplatename)
can you add a couple of screenshots on how the relationships are setup inside the "Configure" tab of DRB? according to the URLs you posted, DRB is creating the URLs using the ReferencedEntityNavigationPropertyName (dcntrcrm_documenttemplate_reportdefinition) are you sure that dcntrcrm_reporttemplate_reportdefinition is the schema name of the relationship? can you post a screenshot of the relationship as well? Thanks
Sure, here you go
Here is the screenshot of the relationship setup in DRB
It seems DRB used the relationship schema name instead of ReferencedEntityNavigationPropertyName?
This the screenshot of the Dataverse relationship
For one-to-many (and also many-to-many) the schema name is used, the relevant code for the expand is at this line: https://github.com/GuidoPreite/DRB/blob/main/js/drb.generatecode.js#L50 The other important part (but not the only one sadly) is the GetCodeFields (practically the part where the relationship name is used to get the fields. https://github.com/GuidoPreite/DRB/blob/main/js/drb.generatecode.js#L792
To be honest I don't know when I have the time to check and try to fix this behavior, I will try to replicate the table names you have and also create the same relationship as you have.
I was trying to generate a query with $expand clause to a related entity with a one-to-many relationship and DRB generated the query with the wrong property name. The reason is probably that the table was renamed and DRB should take the ReferencedEntityNavigationPropertyName instead of relationship schema name. This is what I see in the make portal and what DRB takes to build the $expand clause
This is what it is shown in Metadata browser
If I replace the schema name in the query with the ReferencedEntityNavigationPropertyName the query works as expected, otherwise it just throws the "Could not find a property named ..." error.