Solved

GET custom field generates an error

  • 1 August 2023
  • 4 replies
  • 65 views

Userlevel 4
Badge

I am attempting to get the Tax Rate from a SalesInvoice.
I have created a custom field - in SalesInvoice->TaxDetails I added TaxRate with the Mapped Object Taxes and the mapped field Tax Rate.

I am calling this field, and others with a GET request to the following:

/entity/[My Custom Endpoint]/22.200.001/SalesInvoice?%24filter=CustomerOrder%20eq%20'nnnnnnnnnnn'&%24expand=Details,TaxDetails&%24select=CustomerID,CustomerOrder,ReferenceNbr,Description,Amount,Status,Details%2FOrderNbr,TaxDetails%2FTaxRate


Without my custom field in the URI the result is as expected.
With my custom field I get:

 "Optimization cannot be performed.The following fields cause the error:\r\nTaxDetails.TaxID: View Taxes has BQL delegate\r\n",


How can I get the data from my custom field? Or, do I need to set the custom field up differently?

icon

Best answer by rcreasy 1 August 2023, 21:12

View original

4 replies

Userlevel 7
Badge +5

The challenge is that the Taxes view has a view delegate and thus the API doesn’t want to return all of the records because each record in the Taxes view is likely performing some sort of database lookup and separate processing.

Given that taxes are likely to be a low number of records for a given order you could look at adding another view to the graph that is used to expose the TaxTran records related to the invoice. This will require that you add a tab to the screen but you can hide that as required so you don’t throw off the users.

Userlevel 4
Badge

I was able to solve this issue by making a separate call to the individual invoice to pull just the TaxRate.

In case it helps someone in the future, here is what I did.

With the first call I get the info I need other than the TaxRate:


/entity/[My Custom Endpoint]/22.200.001/SalesInvoice?%24filter=CustomerOrder%20eq%20'nnnnnnnnnnn'&%24expand=Details&%24select=CustomerID,CustomerOrder,ReferenceNbr,Description,Amount,Status,Details%2FOrderNbr

 

Then, using the ReferenceNbr from the above, I make the call:

 

entity/[My Custome Endpoint]/22.200.001/SalesInvoice/Invoice/[ReferenceNbr from the call above]?%24expand=TaxDetails&%24select=TaxDetails%2FTaxRate

 

@Django from your explanation above, I am assuming the first call actually looks at all SalesInvoices, but filters them based on the filter. And, that is the reason it fails. My second call above looks at just one specific SalesOrder, and avoids the issue. 

HTH someone

Userlevel 7
Badge +5

Oh good!  Yes, I’m so used to querying multiple records that I forgot about this. I knew there had to be a way!

Userlevel 7
Badge

Thank you for sharing your solution with the community @rcreasy!

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