cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Geoffre_y
Helper I
Helper I

collection to sharepoint list update if

Hello,

 

I broke my list several times on this point,

I would like to update my sharepoint list item with my colection.

would only like to take into value items which are greater than 1 to update my list sharepoint list.

 

my button on select : without the notion of if greater than 1

 

ForAll(
test As Transfert;
Patch(
topic_order;
{ID:Transfert.ID};

{
ID_topic:First(Sort(topic_order;ID_topic;Descending)).ID_topic +1;

Title:"test";

order_topic:Transfert.order_topic;

start_topic:Transfert.start_topic;

end_topic:Transfert.end_topic;
IDmeeting_topic:gl_makemeeting.Selected.ID_meeting

}
)
)

 

Geoffre_y_3-1659717942021.png

 

 

I'm not sure this is the best solution. for update ma sharepoint list from my collection ...

to summarize the goal, I make a clear collect of certain item, the user modifies what he needs and only the modified items must be updated in the sharepoint list

 

thank for your help.

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
WarrenBelz
Super User
Super User

Hi @Geoffre_y ,
Assuming your field is in Test

ForAll(
   Filter(
      test; 
      YourField > 1
   ) As Transfert;
   Patch(
      topic_order;
      {ID:Transfert.ID};
      {
         ID_topic:
         First(
            Sort(
               topic_order;
               ID_topic;
               Descending
            )
         ).ID_topic + 1;
         Title: "test";
         order_topic: Transfert.order_topic;
         start_topic: Transfert.start_topic;
         end_topic: Transfert.end_topic;
         IDmeeting_topic: gl_makemeeting.Selected.ID_meeting
      }
   )
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Visit my blog Practical Power Apps

View solution in original post

Hi @Geoffre_y ,

Then this should work much quicker - ForAll actually creates a Table and providing your unique identifier ID is present in the Table, Patch will update the records in one go instead of "looping" through multiple Patches.

Patch(
   topic_order;
   ForAll(
      Filter(
         test; 
         YourField > 1
      ) As Transfert;
      {
         ID: Transfert.ID;
         order_topic: Transfert.order_topic;
         start_topic: Transfert.start_topic;
         end_topic: Transfert.end_topic;
         IDmeeting_topic: gl_makemeeting.Selected.ID_meeting
      }
   )
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Visit my blog Practical Power Apps

View solution in original post

12 REPLIES 12
WarrenBelz
Super User
Super User

Hi @Geoffre_y ,
Assuming your field is in Test

ForAll(
   Filter(
      test; 
      YourField > 1
   ) As Transfert;
   Patch(
      topic_order;
      {ID:Transfert.ID};
      {
         ID_topic:
         First(
            Sort(
               topic_order;
               ID_topic;
               Descending
            )
         ).ID_topic + 1;
         Title: "test";
         order_topic: Transfert.order_topic;
         start_topic: Transfert.start_topic;
         end_topic: Transfert.end_topic;
         IDmeeting_topic: gl_makemeeting.Selected.ID_meeting
      }
   )
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Visit my blog Practical Power Apps

thank you, it works, I wonder what would happen if instead of the patch we use an update if? would it be faster to send data to the sharepoint list?

I had tried to work directly on the sharepoint list but I encountered "delay" errors on my list too many patches at the same time the list blocked and returned registration errors

HI @Geoffre_y ,

I could have given you a much faster and more efficient Patch code if you did not have that "running" topic_order field and for the same reason, you cannot use UpdateIf.

hi @WarrenBelz ,

what do you mean by running? my fields are modifiable in the collection obtained by a clear collect but I only update them in the sharepoint when all the orders have been "changed"

thank 

Hi @Geoffre_y ,

This bit

ID_topic:
First(
   Sort(
      topic_order;
      ID_topic;
      Descending
   )
).ID_topic + 1;

each "loop" will add 1 to the number in the previously patched record.

 

hi @WarrenBelz ,

 

ok i stopped patching this value id_topic at this place i do it when creating my sharepoint list now. the remaining fields are end,start,order

Hi @Geoffre_y ,

Then this should work much quicker - ForAll actually creates a Table and providing your unique identifier ID is present in the Table, Patch will update the records in one go instead of "looping" through multiple Patches.

Patch(
   topic_order;
   ForAll(
      Filter(
         test; 
         YourField > 1
      ) As Transfert;
      {
         ID: Transfert.ID;
         order_topic: Transfert.order_topic;
         start_topic: Transfert.start_topic;
         end_topic: Transfert.end_topic;
         IDmeeting_topic: gl_makemeeting.Selected.ID_meeting
      }
   )
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Visit my blog Practical Power Apps

Hi @WarrenBelz  ,


indeed, it seems faster to me 🙂 thank you very much.

I still have a small question still in the principle of the update:

 

I use this formula from a combox box to save a multi person field in sharepoint list :

 

With({_itm: gallerie1.Selected.rsp_item; _usr : User()};

UpdateIf(sharepointlist; ID= ThisItem.ID;
{person:
Ungroup(
Table(
{Item:
Table({Department: "";
Claims: "i:0#.f|membership|" & Lower(ComboBox2_3.Selected.Mail);
DisplayName:"";
Email: ComboBox2_3.Selected.Mail;
JobTitle: "";
Picture: ""
}
)
};
{Item:_itm}
);
"Item"
)
}
)
);;

 


so he saved the person who is in my share point list and added the new ones selected in a combobox.

I would like to do the same but in the opposite direction that it deletes the person selected in my combobox

I can't do it use removeif I must be expressing my formula wrong.
do you have an idea ?

 

Thank you for your help.

Hi @Geoffre_y ,

I may also be missing something here, but why the complication creating a Table then ungrouping it. Also ID is unique, so why UpdateIf and you also do not use the _usr parameter.

Patch(
   sharepointlist; 
   {ID: ThisItem.ID};
   {
      person:
      {
         Department: "";
         Claims: "i:0#.f|membership|" & Lower(ComboBox2_3.Selected.Mail);
         DisplayName: "";
         Email: ComboBox2_3.Selected.Mail;
         JobTitle: "";
         Picture: ""
      };
      Item: gallerie1.Selected.rsp_item    
   }
);;

To your question, are you trying to delete the record or "blank" the person field ? To delete the record

RemoveIf(
   sharepointlist; 
   ID = ThisItem.ID
)

To blank the Person field

Patch(
   sharepointlist; 
   {ID: ThisItem.ID}
   {
      person:
      {
         Department: "";
         Claims: "";
         DisplayName: "";
         Email: "";
         JobTitle: "";
         Picture: ""
      }
   }
);;

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Visit my blog Practical Power Apps

 

Helpful resources

Announcements
October Events

Mark Your Calendars

So many events that are happening this month - don't miss out!

Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Users online (2,531)