Skip to main content
Solved

GET custom field generates an error


rcreasy
Varsity I
Forum|alt.badge.img

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?

Best answer by rcreasy

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

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

4 replies

Forum|alt.badge.img+6
  • Captain II
  • 554 replies
  • August 1, 2023

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.


rcreasy
Varsity I
Forum|alt.badge.img
  • Author
  • Varsity I
  • 73 replies
  • Answer
  • August 1, 2023

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


Forum|alt.badge.img+6
  • Captain II
  • 554 replies
  • August 1, 2023

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


Chris Hackett
Community Manager
Forum|alt.badge.img
  • Acumatica Community Manager
  • 2754 replies
  • August 1, 2023

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


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