cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
CYJ
Helper II
Helper II

How do i add more values to collection in powerapps?

Hello everyone,

 

I am trying to add the values from two label input into the collections but i am receiving this error

CYJ_0-1592891921816.png

 

Is it possible to do so?

1 ACCEPTED SOLUTION

Accepted Solutions
v-yutliu-msft
Community Support
Community Support

Hi @CYJ ,

Yes, the reason why you met this problem is that there's no Test8 already.

You need to firstly have a collection named Test8, then use patch function to add records for collection Test8.

For example:

Collect(Test,{author:""});
ClearCollect(test2,Split(AuthorInput.Text,","));
ForAll(test2,Patch(Test,Defaults(Test),{author:Result}));
ClearCollect(test3,Split(Label1.Text,","));
ForAll(test3,Patch(Test,Defaults(Test),{author:Result}));

 

 

Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

10 REPLIES 10
Rahber
Super User
Super User

The reason for that is because Split return data type Table and Label1.Text is a text data type. So the two items are of different data types

Try this

Collect(Test, {author: First(Split(TextInput4.Text,",")).Result},{author: Label5.Text})

I am using the First here to get the first part of the substring. You can use Last or as per your need.
v-yutliu-msft
Community Support
Community Support

Hi @CYJ ,

Could you tell me the data type of author field?

Please notice that Split(authorinput.text,",") will return a table, while label1.Text will return a text.

You could not update the same field with two different data structure.

Since the record number that "Split(authorinput.text,",")" returns is dynamic, so you need to create another collection for this. Then use this collection to update author field.

Try this formula:

ClearCollect(test2,Split(AuthorInput.Text,","));
//create another collection for split result
ForAll(test2,Patch(Test,Defaults(Test),{author:Result}));
//update multiple records in Test collection by using data in test2 collection
Collect(Test,{author:Label1.Text})

 

Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @v-yutliu-msft ,

 

I need them in the same collection table. 

v-yutliu-msft
Community Support
Community Support

Hi @CYJ ,

I patch data all to Test collection.

Test2 collection is just another collection that stored the temporary data.

 

 

Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @Rahber ,

 

How do i get all of them? Using first, i would only be getting the first value in the collection (the same goes to last vice versa).

Hi @v-yutliu-msft ,

 

 

Ok i got it what you mean and its working. But now i noticed i need to split the label1.text as well. So how do i stored them it the same table collection?

v-yutliu-msft
Community Support
Community Support

Hi @CYJ ,

Same principle.

Firstly save split result for label1 to another collection, then collect data to Text collection.

Try this:

ClearCollect(test2,Split(AuthorInput.Text,","));
ForAll(test2,Patch(Test,Defaults(Test),{author:Result}));
ClearCollect(test3,Split(Label1.Text,","));
ForAll(test3,Patch(Test,Defaults(Test),{author:Result}));

 

 

Best regards, 

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

You can use:

Collect(CollectionName, {author: Concat(Split(AuthorInput.Text,","),Result & ";")},{author: Label6.Text});

 

Please accept it as a solution if it resolved your problem or up vote if it helped you in anyway!

Regards,

Rahber

Hi @v-yutliu-msft ,

 

Did i miss anything? I dont get why i am facing this error. Do i need to create a collection for test8?

CYJ_0-1592907521466.png

 

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (1,597)