Skip to main content
Solved

ODataV4 Expand followed by Select not working


Forum|alt.badge.img

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?

Best answer by Leonardo Justiniano

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.

 

View original
Did this topic help you find an answer to your question?

6 replies

Leonardo Justiniano
Jr Varsity II
Forum|alt.badge.img+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


Forum|alt.badge.img
  • Author
  • Freshman I
  • 10 replies
  • April 3, 2024

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

 

 

 


Leonardo Justiniano
Jr Varsity II
Forum|alt.badge.img+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.

 


Forum|alt.badge.img
  • Author
  • Freshman I
  • 10 replies
  • April 3, 2024

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


Leonardo Justiniano
Jr Varsity II
Forum|alt.badge.img+4
dannygraham wrote:

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!


Forum|alt.badge.img
  • Author
  • Freshman I
  • 10 replies
  • April 3, 2024

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


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings