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

Remove unwanted column from collection

Hi All,
I am creating app for offline. And app On Start I am doing this-
If(
Connection.Connected,
ClearCollect(
BusStopCollection,
'Bus Stops'
);
SaveData(
BusStopCollection,
"SaveitemstokeepbusStop"
),
LoadData(
BusStopCollection,
"SaveitemstokeepbusStop",
true
);

Further, I am using few columns from collection and using other column. Now I wanted to remove other columns from collection and want to keep only required column.
I tried using Showcolumn and dropcolumn but both giving me error where I used patch function. How can I achieve that?

8 REPLIES 8
Highlighted
Memorable Member
Memorable Member

Re: Remove unwanted column from collection

Hi @Tejasvi_munge 

You can use the below code for Drop the columns.

DropColumns(MenuDataColl,"Item")

Thanks,

 Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

Highlighted
Super User III
Super User III

Re: Remove unwanted column from collection

Hi @Tejasvi_munge ,

I am not sure where your Patch reference comes in as you have not included Patch code, but if you only want to use specific columns in the offline storage, you need to use this

If(
   Connection.Connected,
   ClearCollect(
   BusStopCollection,
   ShowColumns(
      'Bus Stops',
      "Column1Name",
      "Column2Name",
      "Column3Name"
   )
)

Where are you getting the error?

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Highlighted
Helper V
Helper V

Re: Remove unwanted column from collection

Hi @VijayTailor  and @WarrenBelz ,
Thank you your reply,
If I used showcolumn then it showing me below error,

Tejasvi_munge_0-1601383018732.png

It is saying "some " column is missing and when I insert this "some " column in showcolumn then again its asking for another column

How can I resolve this?

Highlighted
Memorable Member
Memorable Member

Re: Remove unwanted column from collection

I think you trying to deleting the createdBy Column, Maybe that is the Reason.

So please if you dropping the columns use the hit n trial method remove 1-2 columns and check if there any error through or Not, check the Code and Make sure the Column you are dropping that nat using in your Code.

Basically, Drop Column remove the Data.

Still issue then mentioned your code with Error in place.
Thanks
Highlighted
Helper V
Helper V

Re: Remove unwanted column from collection

Hi @VijayTailor ,
I have used dropcolumn and showcolumn. But still facing same issue. I trying to deleting many columns not only created by.  I tried dropping 1 at a time as well. Not working

Highlighted
Memorable Member
Memorable Member

Re: Remove unwanted column from collection

Can, you please attach your code.
so will try to work for your Issue.
Highlighted
Helper V
Helper V

Re: Remove unwanted column from collection

Hi @VijayTailor ,
this code is on app on start(from BusStopCollection I want to remove unwanted columns)-
If(
Connection.Connected,
ClearCollect(
BusStopCollection,
'Bus Stops'
);
SaveData(
BusStopCollection,
"SaveitemstokeepbusStop"
),
LoadData(
BusStopCollection,
"SaveitemstokeepbusStop",
true
)
And If I use  showcolumn or deletecolumn then it gives error in below patch function (error attached in previous reply)-
If(
!IsEmpty(JourneyCollection3.cre08_busdrivername3) && Connection.Connected && 1 in JourneyCollection3.flag3,
ForAll(
JourneyCollection3,
Patch(
Journeys,
Defaults(Journeys),
{
cre08_busdrivername: cre08_busdrivername3,
cre08_BusID: cre08_busid3,                    
Journey_ID: cre08_journey_id3,

}
)
);
Clear(JourneyCollection3);
SaveData(
JourneyCollection3,
"Saveitemstokeep3"
)
)

Highlighted
Super User III
Super User III

Re: Remove unwanted column from collection

@Tejasvi_munge ,

As I noted in my original response, DropColumns need to be in the Collect function (or can be in the Items of a gallery), however you cannot do it in conjunction with a Patch.

You can do it here

ClearCollect(
   BusStopCollection,
   DropColumns(
      'Bus Stops',
      "Column1Name",
      "Column2Name",
      "Column3Name"
   )
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

 

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Watch Now

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (6,523)