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

Copy an item in a list and Color a selected gallery

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

 

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Copy an item in a list and Color a selected gallery

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

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
Super User
Super User

Re: Copy an item in a list and Color a selected gallery

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)).  

Community Support Team
Community Support Team

Re: Copy an item in a list and Color a selected gallery

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

 

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

Re: Copy an item in a list and Color a selected gallery

@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

Community Support Team
Community Support Team

Re: Copy an item in a list and Color a selected gallery

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

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors
Users Online
Currently online: 192 members 6,092 guests
Please welcome our newest community members: