cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
mfialek
Level: Powered On

Update a sharepoint list from a collection - creating duplicate entries

I successfully updated my sharepoint list with multiple collections but it's creating 2 entries, one with all zeros and the second entry with the data I passed in the collection.  I know I am using "ForAll" but there should only be one entry in that collection.   

ForAll(csmcollect, Patch(RequestNotifications_FAC, Defaults(RequestNotifications_FAC), {Thresholdkey: CThresholdkey, WorkflowKey: CWorkflowKey, GroupKey: CGroupKey, WorkflowId: CWorkflowId, LowerThreshold: CLowerT, UpperThreshold: CHigherT, GroupId: CGroupId, CurrentStateKey: CCurrentStateKey, RequestKey: IARFORM.LastSubmit.ID, userid: csmdropdown.SelectedText.Mail}));

 

Sharepoint:  See attached.

 
 
 

Any help appreciated

 

 

 

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
Super User
Super User

Re: Update a sharepoint list from a collection - creating duplicate entries

@mfialek 

I know the issue.  You'll want to put CLEAR immediately after the CLEARCOLLECT.

 

ClearCollect(csmcollect, {CThresholdkey: 0, CWorkflowKey: 0, CGroupKey: 0, CRequestKey: 0, CWorkflowId: 0, Cuserid: "", CLowerT: 0, CHigherT: 0, CGroupId: 0, CCurrentStateKey: 0});
Clear(csmcollect);

 

When I was starting to learn about collections I was making a similar error.  You had the right idea to "setup" the collection which assigns the columns and default data types.  But then you must remove the record right after to start fresh with an empty collection.

 

Best of luck building your app!

 

---
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."

View solution in original post

mfialek
Level: Powered On

Re: Update a sharepoint list from a collection - creating duplicate entries

Yes! that did it.  Thanks so much for everyone's help!  

View solution in original post

5 REPLIES 5
Super User
Super User

Re: Update a sharepoint list from a collection - creating duplicate entries

@mfialek 

Can you please show a screenshot of what values are in csmcollect?  There doesn't appear to be anything wrong with your patch so I'm thinking it could be an issue with the original collection.

 

---
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."

dynamicsedge
Level 8

Re: Update a sharepoint list from a collection - creating duplicate entries

@mfialek 

 

Does this one help remove the zeroes? Careful - do this in a test environment - it may delete your stuff!

 

Spoiler
ForAll(RemoveIf(csmcollect,IsBlank('SomePropertThatIsBlank'), Patch(RequestNotifications_FAC, Defaults(RequestNotifications_FAC), {Thresholdkey: CThresholdkey, WorkflowKey: CWorkflowKey, GroupKey: CGroupKey, WorkflowId: CWorkflowId, LowerThreshold: CLowerT, UpperThreshold: CHigherT, GroupId: CGroupId, CurrentStateKey: CCurrentStateKey, RequestKey: IARFORM.LastSubmit.ID, userid: csmdropdown.SelectedText.Mail}));

 

 

 

 

 

mfialek
Level: Powered On

Re: Update a sharepoint list from a collection - creating duplicate entries

 
 

this is how the collection looks like after it's create.  I already have 2 records.  See attached. 

I started with 

ClearCollect(csmcollect, {CThresholdkey: 0, CWorkflowKey: 0, CGroupKey: 0, CRequestKey: 0, CWorkflowId: 0, Cuserid: "", CLowerT: 0, CHigherT: 0, CGroupId: 0, CCurrentStateKey: 0});

 

and use it:

If(reqtotal > 10000 || reqtotal < 25000,

Patch(csmcollect, Defaults(csmcollect), {CThresholdkey: 1, CWorkflowKey: 3, CGroupKey: 8, CRequestKey: 0, CWorkflowId: 1, Cuserid: csmdropdown.SelectedText.Mail, CLowerT: 10000, CHigherT: 25000, CGroupId: 8, CCurrentStateKey: 2});

Super User
Super User

Re: Update a sharepoint list from a collection - creating duplicate entries

@mfialek 

I know the issue.  You'll want to put CLEAR immediately after the CLEARCOLLECT.

 

ClearCollect(csmcollect, {CThresholdkey: 0, CWorkflowKey: 0, CGroupKey: 0, CRequestKey: 0, CWorkflowId: 0, Cuserid: "", CLowerT: 0, CHigherT: 0, CGroupId: 0, CCurrentStateKey: 0});
Clear(csmcollect);

 

When I was starting to learn about collections I was making a similar error.  You had the right idea to "setup" the collection which assigns the columns and default data types.  But then you must remove the record right after to start fresh with an empty collection.

 

Best of luck building your app!

 

---
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."

View solution in original post

mfialek
Level: Powered On

Re: Update a sharepoint list from a collection - creating duplicate entries

Yes! that did it.  Thanks so much for everyone's help!  

View solution in original post

Helpful resources

Announcements
thirdimage

Power Apps Super User Class of 2020

Check it out!

thirdimage

New Badges

Check it out!

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

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