cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
camer314
Resolver I
Resolver I

Why does this ClearCollect not work?

The below code works. It pulls from a custom connector, copies that collection to a staging collection, patches the staging collection and then copies the staging collection back to the original.

 

ClearCollect(recordsSrc, DummyData.DummyGet());
ClearCollect(staging, recordsSrc);
Patch(staging, Index(staging, 1), {id: 99});
ClearCollect(recordsSrc, staging);

 

But then why does this code not work, if we introduce another collection to the mix as below, the final ClearCollect complains about invalid argument type. Is this not the same code as above logically, except now working on a collection copied from a collection? Whats the difference?

 

ClearCollect(recordsSrc, DummyData.DummyGet());
ClearCollect(recordsDest, recordsSrc);
ClearCollect(staging, recordsDest);
Patch(staging, Index(staging, 1), {id: 99});

// Above does not complain, but this here does, but why??
ClearCollect(recordsDest, staging);

 

1 ACCEPTED SOLUTION

Accepted Solutions
camer314
Resolver I
Resolver I

This works as expected, so the original collection has to be sourced from a Table as such:

 

ClearCollect(test1, Table({A: 10}));
ClearCollect(test2, test1);
ClearCollect(test3, test2);
ClearCollect(test2, test3);

 

View solution in original post

5 REPLIES 5

@camer314 

 

If you remove the Patch formula line, does it still complain about ClearCollect(recordsDest, staging)?

@camer314 

 

Whether the Patch removal happens to work or not, the reason could be because once recordsDest and staging have been used, attempting to use them again in the specific way you are doing may cause there to be some difference in schema from before which could result in the error occurring.

Even the below fails, so you must be correct, something is causing it to go a bit crazy (again the last line fails)

 

ClearCollect(test1, {A: 10});
ClearCollect(test2, test1);
ClearCollect(test3, test2);
ClearCollect(test2, test3);

 

camer314
Resolver I
Resolver I

This works as expected, so the original collection has to be sourced from a Table as such:

 

ClearCollect(test1, Table({A: 10}));
ClearCollect(test2, test1);
ClearCollect(test3, test2);
ClearCollect(test2, test3);

 

camer314
Resolver I
Resolver I

This works as expected, so the original collection has to be sourced from a Table as such:

 

ClearCollect(test1, Table({A: 10}));
ClearCollect(test2, test1);
ClearCollect(test3, test2);
ClearCollect(test2, test3);

 

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

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