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

Add new column in collection

Hi everyone,

In my app I have a gallery with some different items. The data source is Excel and it have 6 columns. I've made a collection, so when you click on one of the item in the gallery then it collects all the data. Used following syntax:

 

Collect(CollectedItems, ThisItem); Navigate(NextPage, Fade)

It works perfectly and the collections collects all 6 columns, but I want to add a new column in my collection with the date and time the item was pressed. So when I press one of the items then it collects "ThisItem" but also date/time.

 

Best regards,

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User
Super User

Re: Add new column in collection

Hi @seryil 

I think the reason why this doesn't work is because ThisItem refers to a single record, whereas AddColumns operates against a table/set of records.

The Patch function should hopefully carry out what you expect.

 

Collect(CollectedItems, 
Patch(ThisItem, {CreatedDateTime:Now()})
);
Navigate(NextPage, Fade)

 

 

 

View solution in original post

4 REPLIES 4
Highlighted
Super User
Super User

Re: Add new column in collection

@seryil
Make this change to your code to add the date and time

Collect(CollectedItems, AddColumns(ThisItem, “CreatedDateTime”,Now())); Navigate(NextPage, Fade)

—-
Please Accept as Solution if this post answered your question so others may find it more quickly. If you found this post helpful consider giving it a Thumbs Up.
Highlighted
Helper I
Helper I

Re: Add new column in collection

Hi @mdevaney ,

 

It doesnt work. I get the following error:

 

Skærmbillede 2019-10-26 kl. 22.55.13.png
It says "Invalid Argument Type" to "ThisItem".

Highlighted
Super User
Super User

Re: Add new column in collection

@seryil 

My bad.  ThisItem is a record so we are getting an error because we cannot use Collection modification function on records.  Therefore we have to make a temporary collection to convert from record to collection and then clear it after the operation is completed.  Put all of this code in the OnSelect property of your button.

 

ClearCollect(TempCollection,ThisItem);
Collect(CollectedItems,AddColumns(myTempCollection,"CreatedDateTime",Now()))
Clear(TempCollection);

---
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
Super User

Re: Add new column in collection

Hi @seryil 

I think the reason why this doesn't work is because ThisItem refers to a single record, whereas AddColumns operates against a table/set of records.

The Patch function should hopefully carry out what you expect.

 

Collect(CollectedItems, 
Patch(ThisItem, {CreatedDateTime:Now()})
);
Navigate(NextPage, Fade)

 

 

 

View solution in original post

Helpful resources

Announcements
secondImage

Demo-Extravaganza 2020

Check out these cool Power Apps & vote on your favorite!

secondImage

Robotic Process Automation

Let's talk about the solution provided by Microsoft for Robotic Process Automation (RPA)

secondImage

Community Highlights

Check out whats happening in Power Apps

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

Top Solution Authors
Top Kudoed Authors
Users online (5,688)