Generic Inquiry Access Through OData: Data Retrieval
To retrieve data by using the generic inquiry–based OData interface, you append the generic inquiry name and various parameters to the base URL of the generic inquiry–based OData interface, as described in the sections below. For details about the base URL, see The URL of the Inquiry-Based OData Interface.
Retrieving the Results of a Generic Inquiry
To view the results of an exposed generic inquiry, you append /<GI_Name> to the URL of the generic inquiry–based OData interface. In the URL, you use the name of the generic inquiry that is specified in the respective EntitySet element.
For example, you would specify the https://sweetlife.com/erp/t/U100/api/odata/gi/BI-Customer URL if the following are true:
- The URL of the MYOB Acumatica instance is https://sweetlife.com/erp.
- The instance contains the U100 tenant.
- You want to obtain the results of the BI-Customer generic inquiry.
Retrieving the Results of a Generic Inquiry with Parameters
To specify the values for the parameters of a generic inquiry and obtain the results of the generic inquiry, you do the following:
- You append /<GI_Name_WithParameters> to the URL of the generic inquiry–based OData interface. In the URL, you use the name of the generic inquiry that is specified in the respective FunctionImport element.
- You specify the values of the parameters of the generic inquiry in parentheses.
For example, you would specify the https://sweetlife.com/erp/t/U100/api/odata/gi/DBStorageDetailsByItemWarehouseLocation_WithParameters(Warehouse='WHOLESALE') URL if the following are true:
- The URL of the MYOB Acumatica instance is https://sweetlife.com/erp.
- The instance contains the U100 tenant.
- You want to obtain the results of the DB-StorageDetailsByItemWarehouseLocation generic inquiry for the WHOLESALE warehouse.
You can also use parameter aliases. You may find them useful if the parameter value includes symbols that cannot be used in the URL. In this case, you can move the parameter value to the query part. The example above can be rewritten with a parameter alias as follows: https://sweetlife.com/erp/t/U100/api/odata/gi/DBStorageDetailsByItemWarehouseLocation_WithParameters(Warehouse=@1)?@1='WHOLESALE'
Filtering and Ordering the Results of a Generic Inquiry
You can filter and order the data of an exposed generic inquiry. In the URL, you use a question mark to start the list of parameters, such as $filter and $orderby. To specify multiple URL parameters, you use the & character between the parameters.
For example, you use the https://sweetlife.com/erp/t/U100/api/odata/gi/SO-BI-SalesOrdersForYear?$filter=Customer eq 'GOODFOOD' and OrderTotal ge 1000&$orderby=OrderTotal asc URL if the following are true:
- The URL of the MYOB Acumatica instance is https://sweetlife.com/erp.
- The instance contains the U100 tenant.
- You want to obtain the results of the SO-BI-SalesOrdersForYear generic inquiry.
- You need to retrieve the results only for the GOODFOOD customer and with a sales order total that is greater than or equal to $1000.
- You want to order the results by the order total ascending.
For more information on OData parameters, see https://www.odata.org/documentation/. For the list of items that are not supported by OData in MYOB Acumatica, see Generic Inquiries and OData: Preparation of an Inquiry for Exposure.
Retrieving Custom and User-Defined Fields
In a customization project, you can add custom fields to MYOB Acumatica forms. You can also add user-defined fields to MYOB Acumatica forms. (For details about user-defined fields, see User-Defined Fields.)
To retrieve custom and user-defined fields through the generic inquiry–based OData interface, you need to add these fields to the results of a generic inquiry exposed via OData. For details about how to add user-defined fields to generic inquiry results, see Attributes and User-Defined Fields in Inquiry Results.