Hello! I'm newish to outsystems and I'm trying to populate a combo box dropdown with data according to the first one. I'm getting my data as json from rest api. How should I approach this problem? I have completed the course "Traditional web development" and I have quite a lot previous experience with data handling in front end from react/javascript languages, but I'm really having trouble with solving this.I have defined an input variable in the rest api request and I want it to be defined by the first combo box selected value.
Hi Roni,
I have checked the shared oml file and for the metioned use case I would suggest you the following approach.
Implementation Steps:
1) Define a local variable (RoverCameraList) of Camera List type
2) In the Camera Dropdown map the newly defined local variable as SourceRecordList
3) For both the dropdown map the Source Identifier Attribute field with the Id attribute
4) In the Preperation action flow Filter out the Camera list by the RoverId using ListFilter System action as shown below
5) In the Rover Dropdown OnChange action flow introduce the same filter logic with an additional Ajax node to refresh the Camera Dropdown with the Filtered out list
See this sample : MarsRoverSelection
Refer to the attached .oml file
I hope this helps you!
Kind regards,
Benjith Sam
Hello and thanks for your suggestions! I tried your solution, but Im not getting any data from 3 first objects, only object that returns camera data is perseverance. Did you have the same problem?
Yeah that's correct. Sorry! I made a slight mistake in the Filter logic. To make it work, make a code change in the (Preparation & CameraSelectByRover action flow) ListFilter node SourceList and Condition as mentioned below (and also update the assignment node accordingly)
SourceList: GetRovers.Response.Rovers Condition: Id = RoverSelectId
Note: You need to filter the Rovers list to get the List of Camera associated with it.
Thanks alot for the help, it works now! I figured it had something to do with the filters.
You're welcome, Roni. Glad to help you :)
Hi @Ronivil ,
You can use onchange action for that first combo box, in onchange action, filter and refresh the list result for second combobox and use ajax refresh.
Thanks, Aadhavan S
Hello and thanks for your answer!
I didn't thought quite understand how I should refresh data. I am consuming a REST API where I must get 2 different lists. And the second rest api call should have attribute according the first combo box. Is there an example where this is done?
Could you please share sample OML ?
Sure
This might help to understand the concept https://youtu.be/uVmAtGeRg2M
Hello Roni,
Please check below post,
There is one OML file you can refer it.
https://www.outsystems.com/forums/discussion/36893/drop-down-list-based-on-another-drop-down-list/https://www.outsystems.com/forums/discussion/60227/fill-second-combobox-depending-on-first-combobox-value/ I hope it will help you.
Regards,
Ajit Kurane.
Thanks for the links. I have viewed them before but it seems that they are using database inside outsystems, right? I dont really know how to modify that to work with rest apis and json.