cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

How to Remove and Add items in gallery. If items are split text.

Hi all, 

 

I have got a column that collects a text with a delimiter ",". And I wanted to put this into a gallery and show as an Items and control that particular collection using Gallery features such as Remove. And then keep the updated one. 

 

Here's an example case. 

 

I have got a text or Data  that looks like this - Autodesk Civil 3D,Autodesk Map,Autodesk Plant 3D

 

And I have used Split function in PowerApps which results as show below -

 

Used logic  Split(approvingrequest.X_x002d_NotRelevant,",")

 

ashwnaidv100_0-1601458525707.png

 

I have taken this output as an item to my gallery. And I got something like this. and which is perfect.

ashwnaidv100_2-1601458800675.png

 

Now my question is how would i Remove and Add these particular item and still be able to get back get all the new texts. 

 

 

Any help and workaround would be really appreciated. 

 

Thanks you 

Ash

 

1 ACCEPTED SOLUTION

Accepted Solutions

@Anonymous 

This seems quite different than what I had understood your issue to be with.  Perhaps it is a second part to the issue.

 

Anyway, if you want to add all the selected items in the ComboBox to the Gallery, then consider changing your formula to this:

ForAll(ComboBox3.SelectedItems,
    Collect(approvalonlevel5, {Result: Software_name})
)

That will add any items in the combobox selected into the collection by the Software_Name

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

11 REPLIES 11
RandyHayes
Super User
Super User

@Anonymous 

I am not entirely clear on what you mean by adding and removing in this case.

Are you saying that you want to be able to have new items added to the list, and conversely remove some items from the list?

 

If so, you could do this by manipulating the source string of value that you are splitting.  However, this is most likely going to create a circular reference from your Gallery to the Gallery Items - which will not work.

 

In this case, it might be best to create a collection based on the split of the string and use that as the Items property.  Then within your Gallery (or elsewhere) you could remove and add rows to that collection as needed.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
Anonymous
Not applicable

Hi @RandyHayes , 

 

Yes got it right. 

 

I tried to collect my Split result into collection, It didn't go well. 

 

Can you let me know how to do it as i tried to do it and got below error. 

ClearCollect(approvalonlevel5, Split(approvingrequest.X_x002d_NotRelevant,",").Result)

ashwnaidv100_0-1601477603777.png

 

 

@Anonymous 

First, change your formula to the following:

ClearCollect(approvalonlevel5, Split(approvingrequest.X_x002d_NotRelevant,","))

Next, this needs to be in an Action, such as an OnSelect or OnStart or OnVisible, etc.

You cannot use it directly in the Items property. 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
Anonymous
Not applicable

Thanks @RandyHayes,

 

Remove functionality work like a charm. 

 

But I have having trouble with adding new data into the same collection. 

 

I'm using Add button on which in its OnSelect property I'm using Patch function.

I'm trying to Patch some SelectedItems from a ComboBox.

 

Here a formula : Patch(approvalonlevel5, {Result: ComboBox3.SelectedItems.Software_name})

 

But keep getting an error message from button which says :

error1.PNG

 

Can't understand why this is happening, as I don't wanted to push my data directly to database until/unless all the changes been made with this add and remove feature. 

 

@Anonymous 

Yes, that is not a valid use of Patch for adding records (Patch does not add records).

Consider the following formula instead:

Collect(approvalonlevel5, {Result: ComboBox3.SelectedItems.Software_name})

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
Anonymous
Not applicable

Hi @RandyHayes ,

 

I tried to put Collect instead of Patch, But got this error.

Used code: Collect(approvalonlevel5, {Result: ComboBox3.SelectedItems.Software_name})

 

ashwnaidv100_0-1601696610893.png

 

Here some info that will help you to get clear understanding.

 

From my original post I was using Split function to collect my data, now those Split value is collected in approvalonlevel5.

I just wanted it to manipulate it as, we have got remove already working , now adding ComboBox SelectedItems is became pain.

 

I also tried to Concat the selected items and to Patch it and it works fine, But I can't use Concat as I wanted to be added as a new items, not all in one.

 

Hope this context will help to understand a bit better.

@Anonymous 

Sorry, I over looked something you had from your Patch formula that I should have changed in my last post.  Change formula to:

Collect(approvalonlevel5, {Result: ComboBox3.Selected.Software_name})
_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
Anonymous
Not applicable

@RandyHayes ,

 

Yes this solution actually work, as I mentioned it can be a multiple selection from the ComboBox which is leading it to this error. 

 

I had tested this before. That's why said I can add only one item either by this or by Concat multiple selected item as one. 

 

ashwnaidv100_0-1601825578966.png

As you can see only last selected option has been added to gallery. 

 

I think this logic is still might not the right approach. I can't think of work around.  

@Anonymous 

This seems quite different than what I had understood your issue to be with.  Perhaps it is a second part to the issue.

 

Anyway, if you want to add all the selected items in the ComboBox to the Gallery, then consider changing your formula to this:

ForAll(ComboBox3.SelectedItems,
    Collect(approvalonlevel5, {Result: Software_name})
)

That will add any items in the combobox selected into the collection by the Software_Name

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Helpful resources

Announcements
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Top Solution Authors
Top Kudoed Authors
Users online (2,940)