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

Duplicate rows sharepoint list

Hello

 

I have 2 sharepoint list : Orders / Articles

For one order, I can have any articles.

I would like to copy an order and all the associated articles.

That is really easy to copy one order but I can't find a solution to copy multi articles (so multi rows).

Articles : id_articles / id_order / quality 

20 / 1 / "good"

21 / 1 / "bad"

...

At the end, after the copy, I should obtain : 

22 / 1 / "good"

23 / 1 / "bad"

 

Thanks by advance for your help

1 ACCEPTED SOLUTION

Accepted Solutions
Julien59
Level: Powered On

Re: Duplicate rows sharepoint list

So yes, I want to update multiple records using forAll

 

Do you know where I am wrong of what I coded ?

View solution in original post

8 REPLIES 8
lucia
Level 8

Re: Duplicate rows sharepoint list

Hey,

 

you can try using ForAll function, where you can for each item of your datasource do something.

 

Eg: ForAll(Filter(Datasource, condition), Patch(datasource, defaults(datasource), {order_id: order_id, ...})

 

Hope this helps.

Julien59
Level: Powered On

Re: Duplicate rows sharepoint list

Thanks for your reply but I am not able to use patch / forall with a sharepoint list datasource.

Any other idea ?

 

lucia
Level 8

Re: Duplicate rows sharepoint list

Hey,

 

you can try using collections, to collect the data.

Community Support Team
Community Support Team

Re: Duplicate rows sharepoint list

Hi @Julien59 ,

Do you want to update multiple records?

Could you describe more clearly about the content that you want to update?

 

Usually, we update multiple records like this:

(For example, I update records that Id is equal to 20,21)

1)save items that you want to update to a collection

ClearCollect(collection1,LookUp(listname,ID=20),LookUp(listname,ID=21))

2)update records that Id is equal to 20,21 with the data of "{fieldname1:....,fieldname2:....}".

ForAll(collection1,Patch(listname,ID=[@collection1]ID,{fieldname1:....,fieldname2:....})
//pleace replace the last part to the content that you want to use

Here's a doc about updating multiple records for your reference:

https://powerapps.microsoft.com/en-us/blog/bulk-update-using-forall-and-patch/

 

What's more, ForAll function is used to update multiple records with the same value.

I notice that maybe you want to change 20 to 22, 21 to 23.

If so, I suggest you update record one by one.

Try this:

Patch(listname,LookUp(listname,ID=20),{ID:ID+2});
Patch(listname,LookUp(listname,ID=21),{ID:ID+2});

 

Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Julien59
Level: Powered On

Re: Duplicate rows sharepoint list

Inspired by your answers, I tried this

 

Clear(collArticles);;
Collect(
    collArticles;
   Articles
);;
ForAll(
    Filter(
        collArticles;
        id_orders = DataTable2.Selected.id_orders
    );
    Patch(
        Articles;
LookUp(
                Articles;
                id_orders = DataTable2.Selected.id_orders
            );
        {
            id_articles: Value(Last(Articles).id_articles + 1);
            id_orders: Last(
                SortByColumns(
                    orders;
                    "id_orders";
                    Ascending
                )
            ).id_orders + 1
        ;quality: 
                First(Filter(
                   Articles;
                    id_orders = DataTable2.Selected.id_orders
                ).quality).quality
            )}
        
    )
)

I don't understand how I could replace "FIRST" for "quality" by a right formula

Please find below

 

Source : 

id_articlesid_ordersquality
101good
111bad
121medium

 

Result (2 first columns are right but not the last one !)

id_articlesid_ordersquality
1310good
1410good
1510good

 

That shoud be :

id_articlesid_ordersquality
1310good
1410bad
1510medium
TheRobRush
Level 8

Re: Duplicate rows sharepoint list

edited, someone posted same thing

Julien59
Level: Powered On

Re: Duplicate rows sharepoint list

So yes, I want to update multiple records using forAll

 

Do you know where I am wrong of what I coded ?

View solution in original post

Julien59
Level: Powered On

Re: Duplicate rows sharepoint list

I found the solution using this :

First(
                Filter(
                    Articles;
                    ID = collArticles[@ID]
                ).quality
            ).quality

 

Helpful resources

Announcements
New Ranks and Rank Icons in April

'New Ranks and Rank Icons in April

Read the announcement for more information!

Better Together’ Contest Finalists Announced!

'Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

thirdimage

Community Summit North America

Innovate, Collaborate, Grow - The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors
Users online (3,871)