Skip to main content
Solved

Trying to find items in Acumatica by vendor and vendor code/alternate ID using REST API


  • Jr Varsity I
  • 7 replies

I’m writing a script to automatically process electronic invoices that come in through email and perform several actions after parsing up the invoices and extracting information from them.  I’m kind of new to REST API (I am very familiar with SQL) and so I was wondering how I could write a query that would return the InventoryID of the item based off 1) UPC (barcode) or 2) vendor and vendor code/alternate ID, which are things that are typically included on invoices.  My code is below:

 

Private Sub test()
  Dim ResponseText As String
  
   If RESTQuery("Default/22.200.001/StockItem?$expand=CrossReferences&$select=InventoryID&$filter=CrossReferences/VendorOrCustomer%20eq%20'V000000247'%20and%20CrossReferences/AlternateID%20eq%20'8836'", ResponseText) <> 0 Then
    Debug.Print "Query failed!"
  Else
    Debug.Print "Query successful!"
  End If
End Sub
 

The first part of the error message that is returned is:

 

{"message":"An error has occurred.","exceptionMessage":"The parent value for a property access of a property 'VendorOrCustomer' is not a single value. Property access can only be applied to a single value.","exceptionType":"Microsoft.Data.OData.ODataException","stackTrace":"  …

 

I am trying to write something to the effect of SELECT InventoryID FROM StockItem WHERE (VendorOrCustomer = 'V000000247') AND (AlternateID = '8836')

 

Thanks in advance for any help with this!

Best answer by RohitRattan88

FredL wrote:

 
   If RESTQuery("Default/22.200.001/StockItem?$expand=CrossReferences&$select=InventoryID&$filter=CrossReferences/VendorOrCustomer%20eq%20'V000000247'%20and%20CrossReferences/AlternateID%20eq%20'8836'", ResponseText) <> 0 Then

@FredL reviewing your query seems like you are trying to add a filter on a detail/child entity which is not currently supported. As a workaround, I would suggest creating a Generic Inquiry that has all the fields you need to work with and pull data in your API call using that GI. You could filter as required on GI.

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

2 replies

Forum|alt.badge.img+8
  • Semi-Pro I
  • 715 replies
  • October 13, 2023

RohitRattan88
Acumatica Moderator
Forum|alt.badge.img+4
  • Acumatica Moderator
  • 253 replies
  • Answer
  • October 17, 2023
FredL wrote:

 
   If RESTQuery("Default/22.200.001/StockItem?$expand=CrossReferences&$select=InventoryID&$filter=CrossReferences/VendorOrCustomer%20eq%20'V000000247'%20and%20CrossReferences/AlternateID%20eq%20'8836'", ResponseText) <> 0 Then

@FredL reviewing your query seems like you are trying to add a filter on a detail/child entity which is not currently supported. As a workaround, I would suggest creating a Generic Inquiry that has all the fields you need to work with and pull data in your API call using that GI. You could filter as required on GI.


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