Hi All,
I am working on something where I should have 2 dropdown tags (allowing the user to multiselect in both dropdowns). The first dropdown should populate a list of book "series", while the second dropdown populates a list of "sub series" based on the selections made in dropdown1. For example, if I select "harry potter" in dropdown 1 then dropdown 2 will have "harry potter book1", "harry potter book2", and "harry potter book3". And if the I select "the hunger games" in dropdown 1 then the second dropdown will have all the "subseries" that had "the hunger games" in the "series" attribute in the "TestDropdown" entity . Similarily, if I select both "harry potter" and "the hunger games" , then all the options I just listed will be there. The series and sub series are attributes in an entity called TestDropdown .
Now I am having an issue with populating the second dropdown because I am trying to save the entire list to filter the aggregate of "sub series", but I am only finding an option to use Current and this would only show 1 instead of the full list.
Important to keep in mind is that these dropdowns are in a form and the values in these attributes are to be associated with each book. So when I submit the form, the data about the book goes there and I should somehow relate the series and subseries selected for that book. For this, I thought about having a new entity with bookId as the foreign key, and "series" as well as "Subseries" as 2 more attributes in the new entity. later on all the information about the book as well as the series and subseries should be displayed on a screen.
Later on there should also be another form to edit the book info. (including the skills). So basically, the dropdown tags will then need to be populated with this selections.
Can anyone support with this?
OML file is attached... I have tried working on this on 3 screens: bookDataReview, New, and New2
It would be very much appreciated if I get an example in an oml
if i didn't misunderstood the question then you just want to update your subseries dropdown based on the selection of your series dropdown right?
If yes then to resolve this issue you can follow the below step.
(i) Create a new local variable inside the screen variable (in my solution it is Subseries) with DropdownOption List datatype, and another local variable(in my solution it is named as current series) with just text datatype.
(ii) inside your subseries dropdown set the source property to Subseries. and in on change of series dropdown first clear your Subseries list. then iterate with your selectedOptionList, and refresh your aggregate and add condition based on your currentSeries. later that you just need to append your aggreagate output into your Subseries local variable.
please find the below solution file for more details. inside i added changes in the bookdatareview screen.
let me know if you need any other help😊.
Hi @Darshan Gohil , Thanks alot! Can you attach the updated oml. The file you attached does not have your updates.
the file i attached is already up to date. but below is the screen shots where i made changes.
let me know if you have any queries.
Hi @Darshan Gohil ,
Thanks !
would I be able to display all series and subseries selected with the information about the book?
And would I be able to prepopulate the dropdown with the series and subseries when I want to edit information about the book (including the series and subseries)?
Hi @Rita Foster,
I updated your OML according to your requirements.
Your previous Datamodel was not appropriate for full fill the requirement.
I have updated your data model a little bit.
A Series Entity (to store all Series list).
A SubSeries Entity having Attrubute (SubSeries Name (text), SeriesId(Series Identifier)) [to store all SubSeries List Corresponding to Each Series]
As your know we have 2 dropDows on UI (Series and SubSeries)
Create 2 aggregate to Get Series and SubSeries (GetSeries & GetSubSeries respectively)
Create a Structe also Struc_SubSeriesWithSeriesId
On Screen BookDataReview create a local variables
ListofSelectedSubSeriesWithSeriesId (datatype: Struc_SubSeriesWithSeriesId List),
LocalListofSubSeries (datatype: SubSeries List) &
SeiesIds (datatype: text)
After that we created Onchange Action of Series DropDown and SubSeries DropDown.
In Series DropwOnChangeAction we have
Concat all the Selected Series Ids separated by # and save into local variable SeriesIds (as text) and then refresh GetSubSeries Aggregate to fetch SubSeries List based on Selected Series.
We also added filter
Index("#"+SeiesIds+"#","#"+SubSeries.SeriesId+"#")<>-1
into GetSubSeries aggregate
In SubSeriesDropDown OnChange action
while appendling all the Selected SubSeries we also call a function GetSeriesIdBySubSeriesId which will return SeriesId of Current selected SubSeries and add into LocalVariable' SeriesId attribute.
We also Created 2 more aggregates (GetSerirsForEdit & GetSubSeriesForEdit) to fetch saved Series and SubSeries Incase of EDIT the submitted form.
Also, we required GetSeriesForEdit and GetSubSeriesForEdit aggregate's OnAfterFetch Actions and perform some logic to show pre-Selected Items into Dropdowns In case of Edit the form.
In the DropDown tag Starting selection property parameter we gave local variables.
SeriesDropDown ----> SelectedSeries (local variable)
SubSeriesDropDown---> ListofSelectedSubSeriesWithSeriesId
Lets Come to the Submit button, On Submit Button I have Called Server Action SaveBookReviewData
Inside SaveBookReviewData we have CreatedOrUpdatedBook then we fetched All BookSeriesAndSubSeries Data From database
if we get data (we will get data incase of Edit the form) delete all the old records and then Add New Selected Series and SubSeries Selected from UI.
In above action in last loop we have code is for when User select a series without its subseries (user select a series name but not select any subseries that related this).
Lets test:
Firstly Added Series List
Harry Potter &
the hunger games
Similarly Added some SubSeries For Harry Potter and the hunger games (series)
SubSeries List
Let's Add the Book
I have added with Title: HarryPotterTestBook
also selected Series and SubSeries shown in Image below
Record Added.
Let's Click on HarryPotterTestBook title to edit record.
After Click On Edit (Series and SubSeries Pre-Selected in the form along with another values of Book).
Note: I have deleted some screens into OML don't publish whole OML into your Environment
I also attached OML for your help.
Hope this will help you.
Thanks & Regards,
Sanjay Kushwah
Hi @Sanjay Kushwah ,
Thanks a lot! When I click I choose a series and then select a subseries, there is a small issue there. Because if I unselect a tag from the series dropdown, then the tags in the subseries dropdown get unselected to, but when I save the form, a record is still created in the BookSeriesAndSubSeries Data even though they are supposed to be "unselected".
Hello @Rita Foster,
Right, there was an issue with this scenario.
I have fixed that issue by adding a condition and perform some actions on Series Dropdown Onchange Action.
Attached Updated OML
Thanks @Sanjay Kushwah , I was hoping to get it done using 1 entity for series and subseries, would this be possible?
As you know One series can have multiple Subbseries.
So here one parent record have multiple children record.
It is not possible to save All children record into parent entity else relationship between records will not be established.
Since Your series and Subbseries will be master entity, It will be better to keep them separately.
Please refer this document for better understanding Entity relationships
https://success.outsystems.com/documentation/11/building_apps/data_management/data_modeling/entity_relationships/