Help with adding new items to DropDown Tags
Application Type
Reactive
Service Studio Version
11.10.14 (Build 39806)

I hope you all can help, I am going round and round and I bet its easy and I am going about it the wrong way.

What I want...

A Form:

Inside the form:

A Dropdown Tag list with a default set of items.

I want beside that, an input field where the user can add their own (new item) which will then populate into the Dropdown list (becoming a permanent  item option)

Submit the form that it will add each of those tags as part of a new record.

For example

IF I was doing an Application where user's could submit their meals for the day..

Every day they would go to the app... and submit a new form

In that form they would have three tabs.. breakfast, lunch, dinner.

Under each tab a Dropdown tag where they can select from the prepopulated list from already available records under attributes, Meat, Vegetable, Fruit, Grain - beside that Dropdown tag there is a input field with a button (+ Add to List) -> when clicked it would add that new item to the DropDown Tags (making it a permanent option).

After the user fills out all three downdown tags they submit the form and a new record is written with what they had for breakfast, lunch and dinner.


So far I have a dropdown tag, an input field and an (+ Add to List) button..

I can type into the input field the list option I want to add.. and it gets added.. but it ends up taking the place of one of my current DropDown tags from the list...

I assumed this meant I needed to appendTolist as opposed to assign..

But I just can't get the logic worked out...

I feel like what I should be doing is appending the AddToList variable to DropDown Tags "ItemList" GetEntityName.List

But it doesn't let me do that.. I can assign.. but I can't append to list.. so I know I am totally missing something somewhere.


Thank you for taking the time to read all this, and I really hope you can help!

BTW - if you couldn't tell I am new to OutSystems..


Solution

Hi Ash,

Please find attached the update OML. I have added a new client action to append the newly entered values into the dropdown and on save it will get saved into the item entity.

Kindly review this and let me know, if you need any other help.

Thanks & Kind Regards,

Sachin

ItemsSachin21.oml

Solution

Hi Ash

Some things I saw in your file:

  • The SelectedItemList data type should be DropdownItem List and must be used in the parameter of the selected items in the dropdown, so that you have a selected items variable and have control of those items
  • On DropdownTags Change you have to update the selected items variable. It is just assign CurrentList to SelectedItemList
  • In the action of creating the new item it is necessary to put the name of the new item that will be created. You can expand the source and add the item's attributes. In this case, as this is an action to create, it is not necessary to put the Id, since a new Id will be generated automatically
  • The option to expand source can also be used in ListAppend, where you can add a new id that was created in the action and the name of the created item

Take a look at my file and if you have any questions you can ask

Items.oml

Hi Ash

You are populating the dropdown list with data from an aggregate, and you are creating a new record on this entity when you click on "Add to List" to make it a permanent option , right?

I believe it will work if, after creating the new item record, you refresh the aggregate that populates the list so that the new item appears as an option. If you want the new item to appear already selected, you can append it to the list of selected item after the refresh. Something like this:

Hope this helps

Kind regards

Still can't seem to get it, can you tell me where I am going wrong?

On the SaveOnClick, under ListAppend, If I select "List" and put it as SelectedItemList, it requires the Element field to be filled out...


Thanks, I do really appreciate the help!

Items.oml

Solution

Hi Ash

Some things I saw in your file:

  • The SelectedItemList data type should be DropdownItem List and must be used in the parameter of the selected items in the dropdown, so that you have a selected items variable and have control of those items
  • On DropdownTags Change you have to update the selected items variable. It is just assign CurrentList to SelectedItemList
  • In the action of creating the new item it is necessary to put the name of the new item that will be created. You can expand the source and add the item's attributes. In this case, as this is an action to create, it is not necessary to put the Id, since a new Id will be generated automatically
  • The option to expand source can also be used in ListAppend, where you can add a new id that was created in the action and the name of the created item

Take a look at my file and if you have any questions you can ask

Items.oml

Solution

Hi Ash,

Please find attached the update OML. I have added a new client action to append the newly entered values into the dropdown and on save it will get saved into the item entity.

Kindly review this and let me know, if you need any other help.

Thanks & Kind Regards,

Sachin

ItemsSachin21.oml

Thank to you both! You guys are awesome and thanks to you I got it figured out :)

Much appreciated!

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