Home > Forum > Rules, JS, SQL > User-defined API - mapping nested objects inside list elements to an item list

User-defined API - mapping nested objects inside list elements to an item list
0

Hello,

We are using WEBCON BPS version [version, e.g. 2026]. We are building an endpoint with the User-defined API that receives a list of suppliers. Each supplier should be saved as a row in an item list on the form.
We would like to know whether the User-defined API can handle a structure where each list element contains nested objects, or whether we need to flatten it. I searched the forum for an answer but couldn't find a thread covering this case.

Structure 1 (nested, preferred):

{
"suppliers": [
{
"hqAddress": {
"street": "Domaniewska 1",
"city": "Warszawa",
"postCode": "02-672"
},
"postAddress": {
"street": "Prosta 10",
"city": "Warszawa",
"postCode": "00-001"
}
}
]
}

Structure 2 (flat):

{
"suppliers": [
{
"hqStreet": "Domaniewska 1",
"hqCity": "Warszawa",
"hqPostCode": "02-672",
"postStreet": "Prosta 10",
"postCity": "Warszawa",
"postPostCode": "00-001"
}
]
}

Questions:

1. Can the User-defined API definition map fields of nested objects (e.g. hqAddress.street, postAddress.city) to item list columns? If so, how should the input parameters be configured?
2. If not, is the flat Structure 2 the only option? Or is there another recommended approach, such as accepting the raw JSON and parsing it in an action or business rule?
3. Is support for nested objects inside list elements planned for a future version?

We would prefer Structure 1, because that contract is dictated by the external systems that will call our API.

Thank you in advance for your help.

MVP

Hi Marcin,
As far as I'm aware, Webcon allows only almost flat (an array item may have an object, which is flat, not nested) structure in this case (same as working with Invoke REST API Action).

You could try to use business rule to map some more nested structures using JSON features of SQL Server, but i'm not sure how it will impact generated OpenAPI/Swagger documentation generated by Webcon.

So based on your example this won't work by default mapping (would check if business rules help, but might have a negative impact on Swagger):
{
"suppliers": [
{
"hqAddress": {
"street": "Domaniewska 1",
"city": "Warszawa",
"postCode": "02-672"
},
"postAddress": {
"street": "Prosta 10",
"city": "Warszawa",
"postCode": "00-001"
}
}
]
}

But having something like this should work fine:
{
"suppliers": [
{
"hqAddressStreet": "Domaniewska 1",
"hqAddressCity": "Warszawa",
"hqAddressPostCode": "02-672",
"postAddressStreet": "Prosta 10",
"postAddressCity": "Warszawa",
"postAddressPostCode": "00-001"
}
]
}

In reply to: Maksymilian Stachowiak

Hi Marcin,
As far as I'm aware, Webcon allows only almost flat (an array item may have an object, which is flat, not nested) structure in this case (same as working with Invoke REST API Action).

You could try to use business rule to map some more nested structures using JSON features of SQL Server, but i'm not sure how it will impact generated OpenAPI/Swagger documentation generated by Webcon.

So based on your example this won't work by default mapping (would check if business rules help, but might have a negative impact on Swagger):
{
"suppliers": [
{
"hqAddress": {
"street": "Domaniewska 1",
"city": "Warszawa",
"postCode": "02-672"
},
"postAddress": {
"street": "Prosta 10",
"city": "Warszawa",
"postCode": "00-001"
}
}
]
}

But having something like this should work fine:
{
"suppliers": [
{
"hqAddressStreet": "Domaniewska 1",
"hqAddressCity": "Warszawa",
"hqAddressPostCode": "02-672",
"postAddressStreet": "Prosta 10",
"postAddressCity": "Warszawa",
"postAddressPostCode": "00-001"
}
]
}

We work on extensive processes, where the form scope is also a limitation for us. As a result, we often have to split a single process across several forms. We also do a lot of integrations, and the User-defined API has already been a lifesaver for us. It would be great to see support for domain entities, meaning the ability to receive and map more complex, structured objects (with nested objects and lists) directly onto the process data model, without having to flatten the contract or add intermediate parsing logic.

Are there any plans to extend the User-defined API or the data model in this direction? If this is on the roadmap, we would be grateful for any information on the expected timeline.

MVP
In reply to: Marcin Majka

We work on extensive processes, where the form scope is also a limitation for us. As a result, we often have to split a single process across several forms. We also do a lot of integrations, and the User-defined API has already been a lifesaver for us. It would be great to see support for domain entities, meaning the ability to receive and map more complex, structured objects (with nested objects and lists) directly onto the process data model, without having to flatten the contract or add intermediate parsing logic.

Are there any plans to extend the User-defined API or the data model in this direction? If this is on the roadmap, we would be grateful for any information on the expected timeline.

Hi Marcin

Did you try a UDA with only one text propert e.g. data and transfer your the stringifyed json?
e.g.
{
"data": "{\"suppliers\":[{\"hqAddress\":{\"street\":\"Domaniewska 1\",\"city\":\"Warszawa\",\"postCode\":\"02-672\"},\"postAddress\":{\"street\":\"Prosta 10\",\"city\":\"Warszawa\",\"postCode\":\"00-001\"}}]}"
}

The automation of your endpoint stores the json in a local variable.
Then you use SQL and the JSON_VALUE function to extract the values:

SELECT
JSON_VALUE('Your local Variable', '$.suppliers[0].hqAddress.street') AS HqStreet,
JSON_VALUE('Your local Variable', '$.suppliers[0].hqAddress.city') AS HqCity,
JSON_VALUE('Your local Variable', '$.suppliers[0].hqAddress.postCode') AS HqPostCode,

JSON_VALUE('Your local Variable', '$.suppliers[0].postAddress.street') AS PostStreet,
JSON_VALUE('Your local Variable', '$.suppliers[0].postAddress.city') AS PostCity,
JSON_VALUE('Your local Variable', '$.suppliers[0].postAddress.postCode') AS PostPostCode