cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
BenediktE Helper I
Helper I

Pass selected items from listbox as parameter to restful webservice

Is it possible to get all selected items from a Listbox control as table?

 

For example, I have a web-api that is expecting the following object:

 

{

    userIds: []

}

 

UserIds is an array/table. Than I've a ListBox which contains items of the following structure:

 

{

    "value": "..."

    "userId": "..."

}

 

Now I want to call a web service on a button click and pass all selected user. For example:

 

MyApi.SampleSendDocument({DocumentId: document.Id, Comment: SendCommentTextInput.Text, UserIds: UserListBox.SelectedItems.UserId}); Back()

 

But this is not working. I've tried a lot but could not figure out how to do this.

 

Thank you all!

1 ACCEPTED SOLUTION

Accepted Solutions
Power Apps
Power Apps

Re: Pass selected items from listbox as parameter to restful webservice

PowerApps does not support "arrays". The closest data structure in PowerApps would be a single-column table. If your Web API currently expects UserIds:[value1,value2,...], which is an array, you will need to change the endpoint so it instead expects a column UserIds:[{UserId: value1}, {UserIId: value2}, ...].

 

Then your formula should work:

 

MyApi.SampleSendDocument({DocumentId: document.Id, Comment: SendCommentTextInput.Text, UserIds: UserListBox.SelectedItems.UserId}); Back()

 

I hope this helps.

Radu Gruian [MSFT] ** PowerApps Staff

View solution in original post

2 REPLIES 2
BenediktE Helper I
Helper I

Re: Pass selected items from listbox as parameter to restful webservice

Any news here?

Power Apps
Power Apps

Re: Pass selected items from listbox as parameter to restful webservice

PowerApps does not support "arrays". The closest data structure in PowerApps would be a single-column table. If your Web API currently expects UserIds:[value1,value2,...], which is an array, you will need to change the endpoint so it instead expects a column UserIds:[{UserId: value1}, {UserIId: value2}, ...].

 

Then your formula should work:

 

MyApi.SampleSendDocument({DocumentId: document.Id, Comment: SendCommentTextInput.Text, UserIds: UserListBox.SelectedItems.UserId}); Back()

 

I hope this helps.

Radu Gruian [MSFT] ** PowerApps Staff

View solution in original post

Helpful resources

Announcements
MBAS Gallery 2020

MBAS Gallery 2020

Watch Microsoft Business Applications Summit sessions on-demand.

firstImage

New Ranks and Rank Icons released on April 21!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power Apps Community!

Power Platform 2020 release wave 1 plan

Power Platform 2020 release wave 1 plan

Features releasing from April 2020 through September 2020

Top Solution Authors
Top Kudoed Authors
Users online (7,106)