Generic Inquiry Access Through OData: To Retrieve Data by Using a Generic Inquiry with Parameters
This activity will walk you through the process of retrieving data by using a generic inquiry with parameters.
Story
In the business intelligence (BI) application of the MyStore company, a warehouse manager should be able to view the statistics of the items available in the warehouse. To make it possible for the BI application to display these statistics, you need to retrieve from MYOB Acumatica information about the quantities of stock items that are available in each warehouse. You also need to retrieve these statistics for a particular stock item. You want to use the generic inquiry–based OData interface to obtain this data.
In MYOB Acumatica, you can view the item availability data on the Inventory Summary (IN401000) form. To view the on-hand and available quantities of any stock item on this form, you select the item in the Selection area of the form.
To export the on-hand and available quantities of stock items by using the generic inquiry-based OData interface, you will use the Item Availability Data (INGI0002) generic inquiry, which has been preconfigured for this activity.
Process Overview
You will verify that the Item Availability Data (INGI0002) generic inquiry is exposed through OData, review the results of the generic inquiry in MYOB Acumatica with the parameter specified, and obtain the results of the generic inquiry with the parameter specified through OData.
System Preparation
Before you begin performing the steps of this activity, do the following:
- Deploy an instance of MYOB Acumatica with the name MyStoreInstance and a tenant that has the MyStore name and contains the T100 data.
- Make sure the Postman application is installed on your computer. To download and install Postman, follow the instructions on https://www.postman.com/downloads/.
- Complete the following prerequisite activity: Generic Inquiry Access Through OData: To Sign In to MYOB Acumatica and Retrieve the Metadata.
- If you have created a Postman collection with the basic authentication configured, add a new request to the collection and configure the request to inherit the authorization type from the parent collection.
Step 1: Reviewing the Generic Inquiry
The Item Availability Data (INGI0002) generic inquiry is based on the PX.Objects.IN.INSiteStatus data access class and has one parameter, which you can use to filter the list of stock items by inventory ID. To review this generic inquiry and make sure it includes the needed elements, do the following:
- On the Generic Inquiry (SM208000) form, select the inquiry with the Item Availability Data title in the Summary area.
- Make sure that the Expose via OData check box is selected for this generic inquiry in the Summary area. This means that the generic inquiry results are available through OData.
- Click View Inquiry on the form toolbar to review the resulting generic inquiry form.
- Select a value in the Inventory ID box of the generic inquiry form. Make sure that only one record is returned.
Step 2: Retrieving the Quantities of Items
In Generic Inquiry Access Through OData: To Sign In to MYOB Acumatica and Retrieve the Metadata, you have received the list of fields and parameters in exposed generic inquiries. For each generic inquiry with parameters, the returned list contains a FunctionImport element, which specifies the name of the exposed generic inquiry that is used in an OData request with specified parameters. The list of parameters is available in the respective Function element. You can see that the Function element with the Item Availability Data name includes the InventoryID parameter.
To retrieve the quantities of items, do the following:
- In the Postman collection, add a request with the following settings:
- HTTP method:
GET
- URL: http://localhost/MyStoreInstance/t/MyStore/api/odata/gi/ItemAvailabilityData_WithParameters(InventoryID='AALEGO500')
- HTTP method:
- Send the request. If the request is successful, the response contains the
200 OK
status code. The result is shown in the following code.{ "odata.metadata": "http://localhost/MyStoreInstance/t/MyStore/api/odata/gi/$metadata#Item%20Availability%20Data", "value": [ { "InventoryID": "AALEGO500 ", "Warehouse": "MAIN ", "Description": "Lego 500 piece set", "QtyOnHand": "1999.000000", "QtyAvailable": "1977.000000", "Subitem": "0" } ] }
- Save the request.