web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Copy an item in a list...
Power Apps
Answered

Copy an item in a list and Color a selected gallery

(0) ShareShare
ReportReport
Posted on by 69

Hi everyone,

I'm struggling with two problems in my app

So first,

I have a gallery which shows all the items in my list, I can add new item or edit existing items but I'd like to know if there is a way to copy an item in my galleries and paste them in a new item only with some modifications on the date (I need the current date)

My second blocking point: I'd like to color the selected item in my gallerie, because I have a button which allows my users to delete the selected item with the Onselect action: Remove(ResourceGathering, Gallery2.Selected), but it's not really intuitive for my users

 

Thanks in advance for your help

 

Categories:
I have the same question (0)
  • Drrickryp Profile Picture
    Super User 2024 Season 1 on at

    Hi Free,

     

    With regards to your first problem, I am not certain what it is you want to do exactly. If you simply copy and paste a control, it's value will be static but you can make changes to it.  If you want the second control to change dynamically depending on the value of the first control, you can reference a control on the same or another screen and retrieve its value and then manipulate that. In the example below: on the top row, Label74's Text property is Now(),  The second label's Text property references the first label and subtracts a day.  The bottom row shows a Text input control with its Default property set reflect the day after Label74.Text.  As I said, I'm not sure if that is what you are looking for but I hope it helps.

     

    With regards to coloring an item selected in a gallery, you would use the TemplateFill property of the gallery and insert something like this: If(ThisItem.IsSelected,LightGray,RGBA(0, 0, 0, 0)).  

    dates.PNG
  • v-xida-msft Profile Picture
    Microsoft Employee on at

    Hi @freedumz,

     

    Could you please share a bit more about your scenario?

    Further, could you please share a screenshot about your app's configuration?

     

    For your first question, do you want to copy an item existed within your Gallery and create a new item (only some modifications on date) with the copied data?

     

    I have created a SP list on my side, the data structure as below:4.JPG

     

     

    I have made a test on my side (generate an app from my SP List), please take a try with the following workaround:5.JPG

     

    6.JPG

     

    7.JPG

     

    • Set the OnVisible property of the first screen of your app to following formula:
    Set(IsCopy,false)

     

    • Add a Copy Icon button within the Gallery control (mentioned as above screenshot), set the OnSelect property of the Copy Icon to following formula:
    Set(IsCopy,true);
    NewForm(EditForm1);
    Navigate(EditScreen1,ScreenTransition.Fade,{CopiedItem:ThisItem})
    • Within the Edit screen, unlock the Data card controls (except the Data card that you want to make some modifications. e.g. the Date field Data card) within the Edit form, Set the Default property of the Data card control to following formula:
    If(IsCopy=true,CopiedItem.PropertyName,ThisItem.PropertyName)

    e.g. If you want to retain the value within the Title Data card as that within the copied item, please unlock the Title Data card, set the Default property of this Data card to following:

    If(IsCopy=true,CopiedItem.Title,ThisItem.Title)

      Set the OnSelect property of the "Submit button" control to following formula:

    SubmitForm(EditForm1);Set(IsCopy,false)

    The GIF image as below:Test1.gif

     

     

    For your second question, do you want to color the selected item within your Gallery control? I agree with @Drrickryp's thought almost. I have made a test, please take a try with the following workaround:

     

    Set the TemplateFill property of the Gallery control to following formula:

    If(ThisItem.IsSelected,RGBA(246, 88, 16, 1),RGBA(0, 0, 0, 0))

    The GIF image as below:Test1.gif

     

     

     

    Best regards,

    Kris

     

  • freedumz Profile Picture
    69 on at

    @v-xida-msft

    Thank you for your reply

    For my first question, I have already that in my apps, but I'd like to the same without the edit screen, so I clicked on the button and directly the new item is added in my list, is it possible to do that or I have to pass by the form?

     

    @Drrickryp

    Thank for your solution, it's working well

  • Verified answer
    v-xida-msft Profile Picture
    Microsoft Employee on at

    Hi @freedumz,

     

    If you want to achieve your needs without the Edit screen, I think the Patch function could achieve your needs.

     

    I have made a test on my side, please take a try with the following workaround:

     

    Set the OnSelect property of the "Copy" icon button to following formula:

    Patch(
    '20180822_case2',
    Defaults('20180822_case2'),
    {
    Title:ThisItem.Title,
    TaskName:ThisItem.TaskName,
    Executor:ThisItem.Executor,
    Due_x0020_Date:Now()
    }
    )

    Note: The '20180822_case2' represents the SP list data source within my app, the TaskName, Executor and Due Date are all columns in my SP list. The Due Date represents the date column you want to make some modification on.

     

    On your side, you should type the following formula:

    Patch(
    'YourSPList',
    Defaults('YourSPList'),
    {
    Title:ThisItem.Title,
    Column1:ThisItem.Column1,
    Column2:ThisItem.Column2,
    ...
    Due_x0020_Date:Now()
    }
    )

     

     

    More details about the Patch function in PowerApps, please check the following article:

    Patch function

     

     

    Best regards,

    Kris

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 326 Most Valuable Professional

#2
11manish Profile Picture

11manish 168

#3
sannavajjala87 Profile Picture

sannavajjala87 75 Super User 2026 Season 1

Last 30 days Overall leaderboard