Clone and Edit Logged-In User's Item in PowerApps

Introduction

I will demonstrate how to clone things in PowerApps in this article. In the article below, I'll present the scenario and its steps or screenshots.

Scenario

Clone things by the requester or user to save time on duplicate entries is an interesting requirement. This article will explain how to open the duplicated item immediately in the form and how to clone objects with confirmation messages.

Objective

I've used a common gallery with two icons: one to open the item in a form so you can read or update its details and another to clone it. A popup window asking the user to confirm that they truly want to clone will show up when they click Clone. The item will be cloned, and a second popup asking if the user wants to open the item in edit form will show up if they answer in the affirmative. The item will open in edit form if the user hits yes. The user will be returned to the gallery if they choose to cancel on either of the two popups. The cloned item will show up as the first item in the gallery if the user chooses not to open the item in the edit form (if the gallery is sorted in descending order).

I've included a Clone icon in my gallery to carry out the particular activity. To create a request, save an item in a list, and open an item from the gallery to amend the form, please refer to my article. Only the creator is able to clone their own work in this gallery. Therefore, a formula is added to the visible property to verify whether the logged user is also the item's creator.

Icon

We will be building two groups because we are creating two pop-ups. Let's examine each category separately. Variables will be used to both show and hide Pop Up.

Step 1. Build the First Confirmation Box to Clone the item/request

Important: The group's control sequence should follow the pattern in the image below. Even if there is a random addition of controls, utilize the bring the front menu to bring in the items in the picture below in that order. I'm going to work on the user interface for each control separately and then put them all together. In order to disable background actions, I am aligning the Background rectangle (RectCloneConfirmation), which fills the full screen and is fading, given that every other control has already been added and renamed. On top of the background grayed-out rectangle (RectCloneConfirmation), all of the controls are visible.

Note. We might wonder why a rectangle is not being shown, i.e because a rectangle’s visible property is set to false through a variable. I will share the screenshot below.

Create item

In a similar manner, the Popup Rectangle (RectCloneConfirmSmall) is dragged to the center of the screen in the image below. The smaller rectangle (RectCloneConfirmSmall) has its height and width set as well.

RGDA

Once the label and buttons are in alignment, modify the label's text. ID is maintained in the control known as Subtitle2. Within the gallery, Subtitle2 is the control. 

Text

To improve visibility, change the color of the label text to white. 

Color

Using the group menu, select the necessary control by holding down the Shift key and clicking with

the mouse. Since it is already grouped, the example below is shown to ungroup.

unGroup

Every control in the group is selectable, and we can adjust it as needed.

Step 2. Build a Proposal Pop-Up to edit the Cloned item/request

Give the first group a new name that is acceptable. It is referred to as GrpCloneConfirmation in this instance. Select the group, choose copy, and paste to produce the next popup, which copies the group and all of its controls. Rename the second group and the controls after copying. Both groups will be situated outside the gallery and inside the screen. Do not get confused with the screenshot. I have renamed the controls from copy to clone for better understanding. 

Cloned item

Following the renaming of the second popup control, both groups appear as follows. Additionally, since we are posing a different query to the user, modify the label of the second pop-up. The questions are also visible in the screenshot below.

Copy mode

Step 3. Clone pop-up confirmation methods

To clone the object, we will develop a patch method. The item is saved in the SharePoint list as soon as it is cloned.

All that a No button does is hide the popup window, which leads to the gallery's final appearance. We're going to employ variables with true false values to reveal and hide.

 

Onselect

By pressing the "Yes" button, the object is patched and made clone-able. Here, we'll list the patching formula. 

Clone training

Step 4. Edit Item Pop-Up confirmation methods

All that a No button does is hide the popup window, which leads to the gallery's final appearance. We're going to employ variables with true false values to reveal and hide.

Edit app

A condition to test if the person who produced it is the same as the one who is logged in is shown in this screenshot. This is so because an item may only be cloned on the user's own property. The visibility property of the Clone/clone icon is configured to show only items generated by logged-in users, as seen in the gallery screenshot. 

Copied items

Step 5. Set the visibility of all controls to appear in sequence

In addition to visible properties, properties OnSelect and OnChange also affect visibility.

We should also be aware that subcontrols automatically inherit the value for the same property in groups, regardless of the value supplied to the group. The identical variables are shown as true or false in the screenshot above. All we are doing is giving each group the same variable.

We will first set the variable on the gallery. 

Variable

Assign a variable to the first popup at the visible property.

Visible

Assign a variable to the second popup at the visible property (Edit function takes place post Clone).

Assign Variable

Conclusion

From the above article, we saw how to Clone requests/items using the patch function. There were two popups created for confirmation purposes. After Cloning the requests, the cloned request could be opened in edit mode, as shown in the above article.


Similar Articles