1

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?

2 Answers 2

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.

Sign up to request clarification or add additional context in comments.

Comments

1

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.