I tried to implement this example from Working_with_SAP_Business_One_Service_Layer.pdf page 50:
POST /b1s/v1/QueryService_PostQuery { "QueryPath": "$crossjoin(Orders,Orders/DocumentLines)", "QueryOption": "$expand=Orders($select=DocEntry, DocNum),Orders/DocumentLines($select=ItemCode,LineNum)&$filter=Orders/DocEntry eq Orders/DocumentLines/DocEntry and (Orders/DocumentLines/LineNum eq 0 or Orders/DocumentLines/LineNum eq 1 or Orders/DocumentLines/LineNum eq 2)" }
to JournalEntries, but I could not find the name of the field which links JournalEntry and lines.
I tried this:
{ "QueryPath":"$crossjoin(JournalEntries,JournalEntries/JournalEntryLines)",
"QueryOption":$expand=JournalEntries($select=),JournalEntries/JournalEntryLines($select=Credit)&$filter=JournalEntries/JdtNum eq JournalEntries/JournalEntryLines/JdtNum and JournalEntries/JdtNum eq 155564 and JournalEntries/JournalEntryLines/Line_ID eq 0"}
but got this error:
{ "error": { "code": "201", "message": "Not supported query option: invalid property 'JdtNum' of entity type 'JournalEntryLine'" }}
I tried TransId and some other name variant, but I could not find the solution.
This works, but the query is not optimal, because Reference1 is not in index and sometimes not contains the base document's DocNum:
{ "QueryPath": "$crossjoin(JournalEntries,JournalEntries/JournalEntryLines)", "QueryOption":$expand=JournalEntries($select=),JournalEntries/JournalEntryLines($select=Credit)&$filter=JournalEntries/ BaseReference eq JournalEntries/JournalEntryLines/ Reference1 and JournalEntries/JdtNum eq 155564 andJournalEntries/JournalEntryLines/Line_ID eq 0"}