简体   繁体   中英

CRM dynamics: oData string javascript

Imagine two tables:

TABLE A           |TABLE B
Entity            |Id
Id                |name
Points            |Ranking           

How to use orderby with $expand:

$select=Entity,Id,Points,A_B/name&$orderby=Id asc&$expand=A_B

How can i order by Ranking which is from TABLE B? I've tried:

$select=Entity,Id,Points,A_B/name,A_B/Ranking&$orderby=A_B/Ranking asc&$expand=A_B

Not working It occurs the following error:

:: Error : 500: Internal Server Error: The expression 'IIF((Convert(value(Microsoft.Crm.Extensibility.OrganizationDataServiceVisitingQueryProvider).GetValue(p, value(System.Data.Services.Providers.ResourceProperty))) == null), null,  

What this means?

I believe that you would not be able to sort by field of expanded entity. You should look for other workaround to make that possible.

You can join table B to your ODATA query by using $expand, but unfortunately you can only sort on the primary entity.

You can filter on the expanded entity, so you could potentially reverse your logic and select from B join to A, order on B and then filter on A.

http://blogs.msdn.com/b/crm/archive/2011/03/02/using-odata-retrieve-in-microsoft-dynamics-crm-2011.aspx?Redirected=true

http://msdn.microsoft.com/en-us/library/gg309461.aspx

If you find the OData endpoint to be limiting, you can always opt to use FetchXML. I use https://github.com/paul-way/JCL but there are others on codeplex that offer more functionality. I wrote JCL, so I'm partial.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM