XrmDefinitelyTyped
XrmDefinitelyTyped copied to clipboard
Expand behaviour
I'm struggling to understand how expand works.
I have a built-in entity (quotedetails) that I'm retrieving with XrmQuery.retrieveMultiple
and I want to expand upon it (I have added a bunch of lookups to quotedetails, so it has a couple of N:1
relationships).
In the expand function the parameter is of type interface QuoteDetail_Expand
that does not have all the lookups I have added to quotedetails
only a fraction of it.
Shouldn't this contain all the lookups that have been added to quotedetails
?
How it is decided what goes into QuoteDetail_Expand
and what not?
What about 1:N
relationships? I can query those straight in the ODATA web api, but in this library they are not present at all inside expand.
Thanks for the help.
Hi szmarci
Expand in XrmDefinitelyTyped is somewhat limited due to type constraints that we haven't solved. Expand in XDT works by expanding a lookup attribute on a retrieved record to include the record result that the lookup points to. So you are only able to expand the N:1
attributes. Normally, in the WebAPI, you would also be able to perform further nested expands. This is not possible in XDT.
Regarding your issue with with missing some lookups attributes added to the quote detail. Are you sure you have updates the TypeScript context with the latest changes in your environment? Other wise i am not sure what the issue might be. Can you come with some example so we might recreate the issue on our side?
For 1:N
relationships I would suggest using retrieveMultiple
on the entity you want to "expand" to and find all records which lookup attributes points to record you would to "expand" from.
@TomMalow Thanks for stopping by.
Regarding my issue with the missing lookups, I did pull updates from my environment, but the issue remains. I'll try to demonstrate it with some built-in property on the (also built-in) quotedetail
entity:
{
"_msdyn_salestaxcode_value": null,
"_msdyn_serviceaccount_value": null,
}
This is two lookup property from the web api pulled from a quotedetail
record.
In the typescript interface of QuoteDetail_Expand
, out of this two only one is present:
msdyn_ServiceAccount: WebExpand<QuoteDetail_Expand, Account_Select, Account_Filter, { msdyn_ServiceAccount: Account_Result }>;
On the custom side of things I have Warehouse
, Location
and Sales package
lookups on quotedetail
but only Sales package
is present in the interface.
There are 26 lookups on this entity (including built-in ones) and in the interface 9 shows up.
Thank you for the examples @szmarci
We will look into it on our side and try to replicate the issue. It might take some time so bear with us.