Mapping between more than one object

Hello Team,

I need one help for how to mapping more than one table and i need one to many relation mapping.

In my case, I have created a TrnProduct business object and a TrnOrder business object. The TrnProductId is mapped in the TrnOrder business object as a foreign key. Now, how can I retrieve the TrnOrder details along with the related TrnProduct information?

TrnProduct:

Trn Order

Please help me and please give me the example for CRUD operation for one to many relation mapping

Hello,
I don’t understand what you mean by this :

Could you provide me with a use case example ?

Thanks

In my use case, one product can have many orders. So, when I retrieve the details of a particular order, I also need to get the corresponding product details.

What do you mean by mapping ? Is this about mapped REST APIs ?
If so, @david pointed to different implementations here : Not able to insert the Record form DB using Rest API - #6 by david

Hello Team,

By Mapping means Association(one Bo to another BO).

How to get the product details from order?

In this case, this is done by adding the linked objet’s (the product) field(s) to the order object.
Have you gone through the tutorial Introduction | Simplicité Documentation ?
There’s a step by step guide of what you’re trying to achieve here : Adding the product price field to the order business object

Mapping means, In the mapping, the Product table and the Order table are related, where ProductID is a foreign key in the Order table. I need to retrieve the details of a specific order along with its associated product details. using Mapped rest API.

Hello,

Can you please install the Demo custom APIs module from the App store ?

You will find the DemoAPI1 example of a Mapped REST webservice.

In the Settings field, the JSON describes the mapping of your API. If you wish to add the Order object and it’s linked Product, you need to add it’s definition to the JSON.

Example :

{
	"ping": true,
	"objects": [
		[...]
		{
			"name": "orders",
			"fields": [
				{
					"field": "demoOrdNumber",
					"name": "number",
					"desc": "Order number"
				},
				{
					"field": "demoOrdPrdId.demoPrdName",
					"name": "productName",
					"desc": "Prodcut name"
				}
			],
			"object": "DemoOrder",
			"desc": "Orders"
		}
		[...]
	],
	"name": "Custom mapped API",
	"embedLinks": true,
	"version": "v1",
	"spec": 3,
	"desc": "This is a custom **mapped** API of the demo application for the following business objects:\n\n- Suppliers\n- Products\n- Orders\n- Statistics"
}

Does this help ?

In the above JSON structure, the supplierId in the product table is mapped using the refFields configuration. How can I link the Supplier business object with the Product business object?

mapped supplierid in product table {
“ping”: true,
“objects”: [
{
“name”: “suppliers”,
“fields”: [
{
“field”: “demoSupCode”,
“name”: “code”,
“desc”: “Supplier code”
},
{
“field”: “demoSupName”,
“name”: “name”,
“desc”: “Supplier name”
}
],
“object”: “DemoSupplier”,
“desc”: “Suppliers”
},
{
“name”: “products”,
“refFields”: [
{
“refField”: “demoPrdSupId”,
“refFieldName”: “supplierId”,
“depth”: 10,
“name”: “supplierProducts”,
“refObjectName”: “suppliers”,
“desc”: “Reference to supplier’s row ID”
}
],

here how to link supplier Business Object with Product Business table

These objects are already linked.
When calling /suppliers, the list of products for each supplier is included in the response.
When calling /produts, the supplier’s foreign key is also included in the response.

Could you provide me with an example of the response you are trying to get ?

I have given url like this https://host/api/ext/DemoAPI1/suppliers but its getting error like No object configured for path suppliers

What’s the value of the Settings field ?

I am trying get method only.

{
“ping”: true,
“objects”: [
{
“name”: “suppliers”,
“fields”: [
{
“field”: “demoSupCode”,
“name”: “code”,
“desc”: “Supplier code”
},
{
“field”: “demoSupName”,
“name”: “name”,
“desc”: “Supplier name”
}
],
“object”: “DemoSupplier”,
“desc”: “Suppliers”
},
{
“name”: “products”,
“refFields”: [
{
“refField”: “demoPrdSupId”,
“refFieldName”: “supplierId”,
“depth”: 10,
“name”: “supplierProducts”,
“refObjectName”: “suppliers”,
“desc”: “Reference to supplier’s row ID”
}
],
“fields”: [
{
“field”: “demoPrdSupId.demoSupCode”,
“name”: “supplierCode”,
“desc”: “Supplier code”
},
{
“field”: “demoPrdSupId.demoSupName”,
“name”: “supplierName”,
“desc”: “Supplier name”
},
{
“field”: “demoPrdReference”,
“name”: “reference”,
“desc”: “Product reference”,
“example”: “REF001”
},
{
“field”: “demoPrdName”,
“name”: “name”,
“desc”: “Product name”
},
{
“field”: “demoPrdType”,
“name”: “type”,
“desc”: “Product type”
},
{
“field”: “demoPrdAvailable”,
“name”: “available”,
“desc”: “Product available?”
}
],
“object”: “DemoProduct”,
“desc”: “Products”
},
{
“hidden”: true,
“name”: “stats”,
“fields”: [
{
“field”: “demoOrdStatus”,
“name”: “status”
},
{
“field”: “demoStsCount”,
“name”: “count”
},
{
“field”: “demoStsQuantities”,
“name”: “quantities”
},
{
“field”: “demoStsTotals”,
“name”: “totals”
}
],
“object”: “DemoStats1”
}
],
“name”: “Custom mapped API”,
“embedLinks”: true,
“version”: “v1”,
“spec”: 3,
“desc”: “This is a custom mapped API of the demo application for the following business objects:\n\n- Suppliers\n- Products\n- Statistics”
}

Can you please paste your JSON in a markdown code block ?

Is the user linked to the token you are using granted to the Supplier object ?

@vamsiT did you manage to make this work ?

yes, I have given grant permissions. and i can able to store product data and supplier data separately.

[Predefined Message]

In order for our support team to bring you a better service, and for the rest of the community to find the significant answers more easily, we kindly ask our user to mark as “solved” once a solution has been found.

Your messages indicating that the issue was fixed, we’ve realized this action on your behalf.

This topic was automatically closed 60 minutes after the last reply. New replies are no longer allowed.