Solved

ODataV4 Expand followed by Select not working

  • 25 March 2024
  • 6 replies
  • 76 views

Userlevel 1

Hi There,

I am trying to run a REST query to retrieves some fields at AR Line Level (coming from ARTran) with a couple of fields coming from the ARInvoice header table.

If I start just with the AR Tran part, I have this:

/ODatav4/PX_Objects_AR_ARTran?$select=RefNbr,LineNbr&$filter=RefNbr eq 'AR012031'

which works fine.

I then try to add the expand clause to pull in the related information from AR Invoice. This gets me this:

/ODatav4/PX_Objects_AR_ARTran?$select=RefNbr,LineNbr&$filter=RefNbr eq 'AR012031'&$expand=ARInvoiceByRefNbr

which also works fine.

However - lets say I only want to see the InvoiceDate - I add a select giving me this:

/ODatav4/PX_Objects_AR_ARTran?$select=RefNbr,LineNbr&$filter=RefNbr eq 'AR012031'&$expand=ARInvoiceByRefNbr($select=InvoiceDate)

BANG!

And this rather exciting error message that I can’t make head nor tail of.

   "innererror": {

            "message": "Column DocType is not found in DAC ARRegister. ",

            "type": "PX.Data.PXNotSupportedException",

            "stacktrace": "   at PX.Data.SQLTree.SQLinqExecutor.SQLinqExpressionVisitor.VisitSubQueryProperty(SubQuery subQuery, Type dac, Type propertyType, String propertyName)\r\n   at PX.Data.SQLTree.SQLinqExecutor.SQLinqExpressionVisitor.VisitMember(MemberExpression expression)\r\n   at Remotion.Linq.Parsing.ThrowingExpressionVisitor.Visit(Expression expression)\r\n   at PX.Data.SQLTree.SQLinqExecutor.SQLinqExpressionVisitor.Visit(Expression expression)\r\n   at PX.Data.SQLTree.SQLinqExecutor.SQLinqExpressionVisitor.VisitMemberInit

etc

Any ideas?

Thanks in adavnce.

 

PS: Doing the same thing over SalesLines - and linking back to the header as below:

/ODatav4/PX_Objects_SO_SOLine?$select=OrderNbr,OrderDate&$filter=OrderNbr eq 'SO004375'&$expand=SOOrderByOrderNbr($select=CustomerOrderNbr)

works.

 

Is it possible there’s an underlying error in the join definition server side?

icon

Best answer by Leonardo Justiniano 3 April 2024, 17:02

View original

6 replies

Userlevel 6
Badge +4

Hi @dannygraham 

I see an exception in your listing “PXNotSupportedException” that tells you that you can’t list that field. I did some digging and it seems is not longer used. You might try working with ARRegister instead as ARInvoice inherit from ARRegister. then use DocDate field instead

 

URL/PX_Objects_AR_ARTran?$skip=0&$top=10&$filter=RefNbr eq 'AR012031'&$select=RefNbr,LineNbr&$expand=ARRegisterByRefNbr($select=DocDate)

 

Hope this help

Userlevel 1

Hi Leonardo,

Thanks for taking the time to look into this, much appreciated.

Unfortunately - I don’t think that’s the answer. Sure - you could go after DocDate and conceptually that probably does replace InvoiceDate - but you can pick any column which exists in ARInvoice (other than the key) and get the same error. The TermsID for example. And there isn’t a substitute for that in ARRegister.

The error is weird

Column DocType is not found in DAC ARRegister

If you don’t specify a select column at all - it works and you get back all columns of ARInvoice (joined to ARRegister) for the ARTran record - so it looks like the joins work.

But when you specify a column such as TermsID - it then complains about DocType which isn’t even mentioned in the query. But is pointing back to the join - perhaps because on ARTran the field is called TranType.

 

Either way, this smells of a bug, in the join building code or the join metadata.

Thanks

 

 

 

Userlevel 6
Badge +4

Hi @dannygraham 

Thank you for your feedback. However, my humble opinion is there is a limitation (or bug?) in Acumatica regarding how Acumatica handles ARInvoice and ARRegister classes internally when processing an REST API call. My recommendation above is a workaround. I agree it is confusing because expanding the navigation property works, but trying to select any field of the expanded class does not. You can clearly see the problem in Postman:

Postman GET call

When you look into the implementation the class ARInvoice is inherited from ARRegister

ARInvoice.cs

My suspicions points to the way the class was declared as they share that class between AR transactions and SO transactions.

 

Userlevel 1

Yes - I think you and I are on the same page on this one.

There’s something not right within Acumatica.

Hopefully - someone internal will pick up on it and issue a patch of some sort.

 

Many thanks for your help!

Regards

Userlevel 6
Badge +4

Yes - I think you and I are on the same page on this one.

There’s something not right within Acumatica.

Hopefully - someone internal will pick up on it and issue a patch of some sort.

 

Many thanks for your help!

Regards

I invite you to submit a ticket to Acumatica. They probably know about the issue already, but your insights can give them more clues about how 3rd parties consume their Acumatica API.

Thank you!

Userlevel 1

Unfortunately we’re using a trial version of Acumatica at the moment so we don’t have a formal relationship with Acumatica, beyond what we created ourselves when we registered.

So I don’t think I have rights to do this. I certainly can’t find the place on the site to do it in any case.

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved