Many to many relationship question

Many to many relationship question

  

Hi

I have an Office(s) entity and a Product(s) entity and an Office_Product entity (one office can sell many products and one product can be sold by many offices. Scaffolding give me the screens for Products and Offices. Now, what I want is that in the Product Detail screen for everey Office a checkbox is presented and on saving the checked offices (with the product) is added to the Office_Product entity. 

What is the approach to do this?

Regards, Harry

If i understood your question you want a table of all available products and a checkbox  before it's name, showing if the product is in the office of the detail screen. Is it ?

Hi Harry,

If I have correct understanding, You want to store the product details available or sold by particular office(Only the selected products)?

Sachin

I want in the product detail screen a list of offices with checkboxes. The idea is that I want to select the offices that may sell this product. So on saving the product the checked offices must be added tot the office_product table.

Harry

Hi Harry,

You can add multi List select with the list of the offices on Product detail screen, On Save button you have to traverse a loop for the list of offices you have selected and then have to store into Office_Product table.

Below ER can be refer. Let me know if you still find difficulty, I could create sample for you.

Sachin

Solution

Hello Harry

This is as simple as drag the Office_Product entity to the Product Detail page, below the form.
It is a Master Detail pattern, covered by a scaffolding pattern in Service Studio.

I have a simple example to you. Everything will be ready, including the checkboxes.

Just drag the entity below the form in the detail screen and see the stars ;)

Cheers,
Eduardo Jauch

Solution

P.S.

This will not give "exactly" what you want.
It will give a list to where you can add offices, and a popup to choose the office. 

But it is a very well know pattern and easy to implement.

If, instead, you really need to do as you asked, with the list of offices and the checkboxes, you can do it as Sachin said.

But be careful, because if you have pagination, the checkboxes values are "lost". In this case, you can use the OnChange event to save in the database, or to add/remove to/from a local list the values.

If there are too many offices, the interface will not be friendly.

Cheers,
Eduardo Jauch

EDIT:

I attached an example with the OnChange way.
Hope it will help.

Cheers,
Eduardo Jauch

Thank you all very much. 

I've got it working now! 

PS I must say that the forum (participants) is great, I know very little products where the respons is so fast and really helpfull!

Regards, Harry

Harry, I am also agree with you, this kind of participation is really helping us to solve our many technical challenges. 

I know Eduardo has already gave you the right solution. However, I have also created sample oml, may be you can have a look. 

Sachin

Thank you Sachin.

 I will have a look

Harry

Thanks Sachin


I would like to see you example but I am missing one dependency (FancyMultipleSelect)



Best Regards


Alberto Ferreira wrote:

Thanks Sachin


I would like to see you example but I am missing one dependency (FancyMultipleSelect)



Best Regards


Hi Alberto, Give me sometime I will create and upload solution for you.

Thanks 

Sachin 


Hi Alberto, 

I unable to upload the solution, May its too large in size. 

You can do one thing, you can download the FancyMultipleSelect from forge, Deploy it on your environment and take the reference in the oml that I have provided above.

https://www.outsystems.com/forge/component/535/multiple-select/

Sachin

Thanks Sachin

Always trying to learn something more. Thank for your help. its' work 

Alberto Ferreira wrote:

Thanks Sachin

Always trying to learn something more. Thank for your help. its' work 

Hi Alberto, 

I am happy to hear that It worked for you. Thanks!!

Sachin