Skip to main content

Notifications

Power Apps - Building Power Apps
Unanswered

Patch from one Sharepoint list to another based on gallery

Posted on by 121

Hi,

 

My scenario is I am trying to copy an entire record from one SharePoint list to another based on the selected record within a gallery.

 

Is there a way to do this either manually writing each field as there is only 10 or code to copy in as a one.

 

This is what i tried but getting errors

 

Patch(LogDataALL,Defaults(Archive),
Gallery1.Selected,
{
'Command Type': Label4_2,
'Log Date': Label4
}
);

 

Sharepoint List to be copied from is LogDataALL

Sharepoint List to receive the data is Archive

Gallery from where the record is selected from is Gallery1.

 

Your help is appreciated

Categories:
  • RouxJMM Profile Picture
    RouxJMM 94 on at
    Re: Patch from one Sharepoint list to another based on gallery

    Value_drop.jpg

     

    Also, add .Value for the Command Type

  • Markswan20 Profile Picture
    Markswan20 121 on at
    Re: Patch from one Sharepoint list to another based on gallery

    I have changed the input from the Gallery to a dropdown selection and pointed it to ThisItem.'Command Type'

     

    Used 'Command Type': aRec.Dropdown4.Selected, 

     

    and it seems to have patched the Archive with the drop down field. 

    Fingers crossed its sorted, i'll enter the data for the other field and give you a thumbs up shortly if it works.

     

    Thanks Roux you are a legend 🙂

  • Markswan20 Profile Picture
    Markswan20 121 on at
    Re: Patch from one Sharepoint list to another based on gallery

    Thanks Roux

     

    This is how i created the Archive List by duplicating the actual source, the only records present are the ones that have worked on the last step.

     

    The Command Type column is a dropdown selection on the original List

  • RouxJMM Profile Picture
    RouxJMM 94 on at
    Re: Patch from one Sharepoint list to another based on gallery

    Assuming you are using a Choice column for the Command Type and not a Lookup column, the. what has been posted so far will work.

     

    Maybe something to try is to recreate a destination list (Archive2) based on an existing list (the source).

  • Markswan20 Profile Picture
    Markswan20 121 on at
    Re: Patch from one Sharepoint list to another based on gallery

    We are getting there so thank you, it's patching the text data and the date data but isn't populating the data relating to a dropdown within the SharePoint list. I have tried 

     

    Label14_2 and Label14_2.Text. 

     

    Without .Text it populates the other 2 bits of data but with .Text it states 

     

    The type of the argument 'Command Type' does not match the expected type 'Record' . Found type 'Text'.

     

  • RouxJMM Profile Picture
    RouxJMM 94 on at
    Re: Patch from one Sharepoint list to another based on gallery

    Ok then, try this:

     

    With({aRec: Gallery1.Selected},
     Patch(Archive, Defaults(Archive),
     {
     'Command Type': aRec.Label4_2,
     'Log Date': DateTimeValue(aRec.Label4.Text),
     'GRS': aRec.Label71.Text
     })
    );
  • Markswan20 Profile Picture
    Markswan20 121 on at
    Re: Patch from one Sharepoint list to another based on gallery

    Thanks Roux

     

    I have tried it with and without .Text but its erroring I have attached the error pic.

     

    I have a basic gallery with 3x Text fields linked to the SharePoint. The 3x fields I'm currently trying to patch to are 

    'Log Date' this is powered from a date picker on the List

    GRS this is powered by a standard Text field

    'Command Type' this is powered by a Drop Down in the List

     

    Any ideas

  • RouxJMM Profile Picture
    RouxJMM 94 on at
    Re: Patch from one Sharepoint list to another based on gallery

    You are missing the .Text

    'Command Type': aRec.Label4_2.Text

     

  • Markswan20 Profile Picture
    Markswan20 121 on at
    Re: Patch from one Sharepoint list to another based on gallery

    Thanks for the response,

     

    I had to change the code slightly as the original code had the following error and had a required field. 

     

    The type of this argument 'CommandType does not match the expected type 'Record'. Found type 'Error'.

     

    With({aRec: Gallery1.Selected},
    Patch(Archive, Defaults(Archive),
    {
    'Command Type': aRec.Label4_2,
    'Log Date': aRec.Label4,
    GRS: aRec.Label71
    })
    );

     

    It's showing an error in the status on select, it says

     

    Network error when using patch function. The requested operation is invalid.

     

    Have i missed something simple.

     

    Regards

  • BCLS776 Profile Picture
    BCLS776 8,997 on at
    Re: Patch from one Sharepoint list to another based on gallery

    Try this:

    With({aRec: Gallery1.Selected},
     Patch(Archive, Defaults(Archive),
     {
     'Command Type': aRec.Label4_2.Text,
     'Log Date': aRec.Label4.Text
     })
    );

    Hope that helps,

    Bryan

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

November 2024 Newsletter…

November 2024 Community Newsletter…

Community Update Oct 28…

Power Platform Community Update…

Tuesday Tip #7 Community Profile Tips…

Welcome to a brand new series, Tuesday Tips…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 143,591

#2
RandyHayes Profile Picture

RandyHayes 76,308

#3
Pstork1 Profile Picture

Pstork1 64,090

Leaderboard