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

UpdateIf in ForAll-Loop not working

Hi,

 

I am trying to update multiple items in a sharepoint list with the values of a collection.

 

The collection is called "Customers_Offline_Delete"

The sharepoint list is called "Customers"

 

Unfortunately the sharepoint list is not being updated.

 

Additional note: The column "To_Be_Deleted" was added to the sharpoint list after it was initially created (just in case this might cause the issue).

 

ForAll(
    Customers_Offline_Delete;
    UpdateIf(
        Customers;
        Customers_Offline_Delete[@ID] = ID;
        {To_Be_Deleted: To_Be_Deleted}
    );;
);;

 

Any help is appreciated. Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support
Community Support

Re: UpdateIf in ForAll-Loop not working

Hi @Lukas1 ,

Do you want to multiple records in your SP List based on your Collection data?

Could you please share a bit more about the "To_Be_Deleted" column in your SP List? Is it a Yes/No type column?

 

Firstly, if you added a new column to your SP List after it was initially created, please consider refresh the SP list data source in your app manually.

 

Based on the formula you provided, I think there is something wrong with it. Actually, I think the combination of ForAll function and Patch function could achieve your needs.

I have made a test on my side, please consider take a try with the following workaround (If there is also a "To_Be_Deleted" column in your Customers_Offline_Delete collection😞

Refresh(Customers);;
ForAll(
      Customers_Offline_Delete;
      Patch(
               Customers;
               LookUp(Customers; ID = Customers_Offline_Delete[@ID]);
               {
                 To_Be_Deleted: Customers_Offline_Delete[@To_Be_Deleted]   // I assume that there is also a "To_Be_Deleted" column in your Customers_Offline_Delete collection
               }
     );;
);;

 

If the "To_Be_Deleted" column is a Yes/No type column in your SP List, please consider modify above formula as below:

Refresh(Customers);;
ForAll(
      Customers_Offline_Delete;
      Patch(
               Customers;
               LookUp(Customers; ID = Customers_Offline_Delete[@ID]);
               {
                 To_Be_Deleted: true    // Update SP list records' To_Be_Deleted column to true
               }
     );;
);;

 

Best regards,

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

3 REPLIES 3
Highlighted
Super User
Super User

Re: UpdateIf in ForAll-Loop not working

@Lukas1 

I have 2 ideas for you to try:

 

#1:  Maybe there are no matches here because you are asking is a Table datatype equal to a Number datatype.

 

Customers_Offline_Delete[@ID] = ID;

 

Instead you should ask is the Number datatype IN the Table datatype

 

ID in Customers_Offline_Delete[@ID];

 

#2:  The 3rd argument of UpdateIf is replacing a column value with itself.

 

{To_Be_Deleted: To_Be_Deleted}

 

Perhaps instead you wanted to mark this as true (guessing you are using a yes/no column here).

 

{To_Be_Deleted: true}

 

---
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
Community Support
Community Support

Re: UpdateIf in ForAll-Loop not working

Hi @Lukas1 ,

Do you want to multiple records in your SP List based on your Collection data?

Could you please share a bit more about the "To_Be_Deleted" column in your SP List? Is it a Yes/No type column?

 

Firstly, if you added a new column to your SP List after it was initially created, please consider refresh the SP list data source in your app manually.

 

Based on the formula you provided, I think there is something wrong with it. Actually, I think the combination of ForAll function and Patch function could achieve your needs.

I have made a test on my side, please consider take a try with the following workaround (If there is also a "To_Be_Deleted" column in your Customers_Offline_Delete collection😞

Refresh(Customers);;
ForAll(
      Customers_Offline_Delete;
      Patch(
               Customers;
               LookUp(Customers; ID = Customers_Offline_Delete[@ID]);
               {
                 To_Be_Deleted: Customers_Offline_Delete[@To_Be_Deleted]   // I assume that there is also a "To_Be_Deleted" column in your Customers_Offline_Delete collection
               }
     );;
);;

 

If the "To_Be_Deleted" column is a Yes/No type column in your SP List, please consider modify above formula as below:

Refresh(Customers);;
ForAll(
      Customers_Offline_Delete;
      Patch(
               Customers;
               LookUp(Customers; ID = Customers_Offline_Delete[@ID]);
               {
                 To_Be_Deleted: true    // Update SP list records' To_Be_Deleted column to true
               }
     );;
);;

 

Best regards,

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

Helper II
Helper II

Re: UpdateIf in ForAll-Loop not working

Thank you both!

 

@v-xida-msft, I was able to fix it by using: 

To_Be_Deleted: Customers_Offline_Delete[@To_Be_Deleted]

instead of

To_Be_Deleted: To_Be_Deleted

 

"Patch" and "UpdateIf" are both working fine now. Which one do you recommend in terms of delegation?

 

Thanks a lot!

Helpful resources

Announcements
Check this Out

Helpful information

Featuring samples like Return to the Workplace and Emergency Response Applications

August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

secondImage

Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

secondImage

Super Users Coming in August

We are excited for the next Super User season.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (7,577)