Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

$expand clause is not generated correctly #27

Open
BineG opened this issue May 17, 2024 · 5 comments
Open

$expand clause is not generated correctly #27

BineG opened this issue May 17, 2024 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@BineG
Copy link

BineG commented May 17, 2024

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
image

This is what it is shown in Metadata browser
image

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.

@GuidoPreite
Copy link
Owner

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)

@GuidoPreite GuidoPreite self-assigned this May 17, 2024
@GuidoPreite GuidoPreite added the bug Something isn't working label May 17, 2024
@BineG
Copy link
Author

BineG commented May 17, 2024

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)

@GuidoPreite
Copy link
Owner

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

@BineG
Copy link
Author

BineG commented May 17, 2024

Sure, here you go
image

Here is the screenshot of the relationship setup in DRB
image

It seems DRB used the relationship schema name instead of ReferencedEntityNavigationPropertyName?

This the screenshot of the Dataverse relationship

image

@GuidoPreite
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants