50
Views
10
Comments
multiselect dropdown with api response and display in array list
Question
Application Type
Reactive

Hi, 
 I want to call API and resonse in multi select dropdown when user selected multiple selection dropdown  option need to pass the values as in array.


example: ['slectedvalue1','slectedvalue3, 'slectedvalue3', ]


Please help here.

2023-02-13 15-34-45
BabyBear

Hi Pavan

Maybe you can try this approach. You can check the Oml file for your reference. 


So what I did was to create a Local variable called 'Array' that you will use to pass in your API 

and loop through each record of the 'SelectedOptionList' and build the array string  

Just make sure you clear the 'Array' variable everytime you call the onchange event of the dropdown

Here is the result of that 

DropdownArray.zip
UserImage.jpg
Pavan K

Thanks, I have tried, but the datatype which i am looking for is long integer, that where i got stuck.

2023-02-13 15-34-45
BabyBear

Would you be able to send the oml file ?

UserImage.jpg
Pavan K

Hi Baby Bear,

PFA oml for your reference, and thanks for your help on this. Using Multiselect Forge component.

multiList.oml
2023-02-13 15-34-45
BabyBear

Hi Pavan


I dont think it is possible to store an array format text to an integer variable. what you can do is have a list of integer instead 

UserImage.jpg
Pavan K

Hi BabyBear,

If possible can you share me the example oml file, as i am new to OS

2023-02-13 15-34-45
BabyBear

Basically a List is like an array in Outsystems

multiList.oml
UserImage.jpg
Pavan K

Hi,

I have tried to appened returing  as ) value, my expectation was need to store the user selected value and new value selected in array format [0,1,2]. Could any one help me here



2023-02-13 15-34-45
BabyBear

Would you be able to share an oml with the consumed REST Api?

2023-02-20 05-20-57
Nam Nguyen

Hi Pavan K,

I believe BabyBear has already answerd your quesstion. 

You want to store the user selected value. Please follow BabyBear guildance.

You want to pass values into array in API Body. Based on your image in Postman, you need a structure, then serialize it and send into API body. 

"ColorLayerIdList" is an integer array. So your structure will contain an attribute called ColorLayerIdList which its data type is (Long) Integer List. When serializing, OS will convert to it array.

Regards,

Nam








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