cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Memorable Member
Memorable Member

Patch collection columns

Hello.

 

What am i missing here?

 

I want to Patch entirely new columns in a Collection when a button is pressed. I'm trying to use ForAll in conjunction with Patch, but the error messages states "can't use same data source for both functions".

 

Any ideas for Patching in columns?

 

ForAll(
    collection_name,
        Patch(
            collection_name,
Defaults(collection_name), { x: Rand() * 1266, y: Rand() * 668 } ))
1 ACCEPTED SOLUTION

Accepted Solutions
Community Support
Community Support

Hi @seadude,

 

Could you please share a bit more about your scenario?

Could you please show more details about the collection that you mentioned within your formula?

Further, do you want to add a new record into your collection or replace the entire record values with new values (pseudo-random numbers) within the collection?

 

The error message told that the ForAll function and Patch could not use same collection as data source.

 

If you want to add one new record into your collection, please take a try with the following formula:

Patch(
      collection_name,
      Defaults(collection_name),
      {
       x: Rand() * 1266,
       y: Rand() * 668 
      }
 )

 

If you want to replace the entire record values with new values (pseudo-random numbers) within the collection, please take a try with the following formula:

ForAll(
RenameColumns(
RenameColumns(Collection1,"x","x1"),
"y","y1"
),
Patch(
Collection1,
LookUp(Collection1,x=x1&&y=y1),
{
x:Rand()*1266,
y:Rand()*668
}
)
)

 

More details about the Patch function and ForAll function within PowerApps, please check the following article:

Patch function, ForAll function

 

Best regards,

Kris

Community Support Team _ Kris Dai
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

1 REPLY 1
Community Support
Community Support

Hi @seadude,

 

Could you please share a bit more about your scenario?

Could you please show more details about the collection that you mentioned within your formula?

Further, do you want to add a new record into your collection or replace the entire record values with new values (pseudo-random numbers) within the collection?

 

The error message told that the ForAll function and Patch could not use same collection as data source.

 

If you want to add one new record into your collection, please take a try with the following formula:

Patch(
      collection_name,
      Defaults(collection_name),
      {
       x: Rand() * 1266,
       y: Rand() * 668 
      }
 )

 

If you want to replace the entire record values with new values (pseudo-random numbers) within the collection, please take a try with the following formula:

ForAll(
RenameColumns(
RenameColumns(Collection1,"x","x1"),
"y","y1"
),
Patch(
Collection1,
LookUp(Collection1,x=x1&&y=y1),
{
x:Rand()*1266,
y:Rand()*668
}
)
)

 

More details about the Patch function and ForAll function within PowerApps, please check the following article:

Patch function, ForAll function

 

Best regards,

Kris

Community Support Team _ Kris Dai
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

Helpful resources

Announcements
New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

Top Solution Authors
Top Kudoed Authors
Users online (69,971)