CRM dynamics: oData string javascript

这一生的挚爱 提交于 2019-12-11 08:20:00

问题


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?


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/22047142/crm-dynamics-odata-string-javascript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!