64
Views
7
Comments
one to many
Question

I want the user to add several products in one id. I know that the relationship is one to many, but how do we program the interface and logic? To save several products in one ID

2016-04-22 00-29-45
Nuno Reis
 
MVP

Hello Sh.

To clarify, you don't want several products with one Id. You want a common entity with multiple products (example: an Order or a Delivery can have with multiple products associated).

You can do it in two ways.

The easy one: you first create the Order, and use that Id to add products one by one.

The better one: when you are editing the Order you also fill a List variable with Products and save all at once, getting the OrderId from the CreateOrUpdate.

But you have to start by watching this class to understand the concept.



2022-10-18 07-32-49
Randall Jodache Chetty

Have a look at the training videos. It really helps. There is an example just like your scenario on the Becoming a Reactive Developer course 

2022-12-09 04-50-17
Shubham Doshi

Hello Ahmed,


I have uploaded a demo OML where I have created One to Many Relations with One user with many products as shown below:


OneToManyDemo.oml
UserImage.jpg
Shahad Altamimi

thanks but i know how to do this, my problem with interface and logic  . how can i told the InterFase i want all these product in the same id


for example; i want to do E-shop so i want add a lot of product in the cart to do an order 

2022-12-09 04-50-17
Shubham Doshi

As you can see below product entity has one user identifier.

Headphone & Laptop has been ordered by UserID: 7

Same

Desktop has been ordered by UserID: 10

So by giving User Identifier, you can list many products under same user identifier

2022-11-29 07-50-38
Balamurugan Pandiyan

Hello Sh,


Whenever you are going to save new product details, you have to give userId for that foreign key right. You can pass GetUserId() to Product.userId field. It will automatically get the current userId who logged in on server.


Ex: You are logged in and adding new product detail to table. It will automatically assign to userId to Product.userId. 

Or you can put assign before save action called,


Thanks,

Bala.


2025-09-25 14-38-22
Lokesh Kumar Yadav

You have to create product id identifier in the user table

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.