Store multiple attributes in a single attribute.

0
  The IngredientsSelect Entity is a multi-select option, allowing the Ingredients in the Drink Entity to be selected from several Ingredients in the IngredientsSelect Entity. These multiple selected options are then stored in the Ingredients field of a single Drink Entity. How should I set this up?
asked
3 answers
3

At first create a empty string as shown below

image.png

 

image.png

 

answered
3

Hello Jeff,

         While saving the Drink Object retrieve the IntegrentsSelect list by association and create a variable Integredients and iterate the list and add the Attribute in Integredients variable with comma separated and finally set the Variable in Integredients attribute in Drink object using change object and commit.

answered
0

Your data-definition is very unlike the normal datastructure for this kind of setup. Usually it look like this:image.png

 

But you probably have a usecase for it. Maybe for a drink 'Coffee', you can select from IngredientsSelect "sugar", "sugar and milk", "cinnamon and milk" and "milk". And for a drink 'Tea' you can select only "sugar", "sugar and milk".

The answer of Dhinesh gets you your multiple attributes in one attribute. All I have to add to that answer is:

  • do you use Drink.Ingredients just for showing a text on a screen. If so: ok, you are done.
  • or do you intend to use it for actions as well, actions like calculation of the total price. If so, you best map the list of attributes to a json-string and store that string in Drink/Ingredients.

But in your usecase I would advise to use an entity storing those ingredient combinations:image.png

answered