cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

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
Highlighted
Frequent Visitor

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
Highlighted
Resolver II
Resolver II

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.

Highlighted
Frequent Visitor

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 ?

 

Highlighted
Resolver II
Resolver II

Re: Duplicate rows sharepoint list

Hey,

 

you can try using collections, to collect the data.

Highlighted
Community Support
Community Support

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.
Highlighted
Frequent Visitor

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
Highlighted
Helper V
Helper V

Re: Duplicate rows sharepoint list

edited, someone posted same thing

Highlighted
Frequent Visitor

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

Highlighted
Frequent Visitor

Re: Duplicate rows sharepoint list

I found the solution using this :

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

 

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Find your favorite faces from the community presenting at the Power Platform Community Conference!

Watch Now

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (5,821)