How to SELECT Fields in REST API with Child Business Object?

Hi Everyone,

I would like to know how we can Select Fields from the Child Business Object we when are using REST API GET?

there is an example in the doc for v1.
You need to use expand too:

https://localhost/erpcurrent/api/v1/Erp.Bo.SalesOrderSvc/SalesOrders?$top=2&$expand=OrderDtls&$select=OrderNum,OrderDtls/OrderLine

result:


{
	"odata.metadata": "https://localhost/erpcurrent/api/v1/Erp.Bo.SalesOrderSvc/$metadata#Epicor.RestApi.SalesOrders&$select=OrderNum,OrderDtls/OrderLine",
	"value": [
		{
			"OrderDtls": [
				{
					"OrderLine": 1
				}
			],
			"OrderNum": 5000
		},
		{
			"OrderDtls": [
				{
					"OrderLine": 1
				}
			],
			"OrderNum": 5001
		}
	]
}

3 Likes

I didn’t know about Expand. :thinking:

But I might use a BAQ and the BAQSvc. If you want more control over the shape of the response, I consider an Epicor Function.

1 Like

Only use the biz objects to get data if you need the whole dataset. You really only need that if you’re going to turn around and update the record. Otherwise you’re pulling a lot of stuff you don’t need, and slowing things down.

Create a BAQ and use the BAQSvc or, even better, a function and access the data that way.

I don’t see BAQ SVC anywhere in Swagger

Could you please let me know how can I do this with BAQSvc?

Thank you so much! @Mark_Wonsil @jtownsend

It’s not working when I put @Olga

$select = InvoiceNum,ChangeDate,InvcDtls/InvoiceLine

{
“HttpStatus”: 400,
“ReasonPhrase”: “REST API Exception”,
“ErrorMessage”: “Found a path with multiple navigation properties or a bad complex property path in a select clause. Please reword your query such that each level of select or expand only contains either TypeSegments or Properties.”,
“ErrorType”: “Microsoft.OData.ODataException”,
“CorrelationId”: “d2e84d21-bdbc-4c13-b7dd-cf06d5f83e0c”
}

On the Swagger Home page, it has its own section near the bottom. It is not with the BOs, PROCs, etc

image