Bulk Renaming of Duplicated Power Apps Controls
This post will show you how to do Bulk Renaming of Duplicated Power Apps Controls. This is not a beginner-level method, but you will be able to follow it easily. Once you’ve done it once or twice it’s a massive timesaver.
(until such time as bulk-renaming is an option in the Editor itself)
You have a screen full of forms and controls and you select the screen and choose Duplicate. This recreates everything with _1 appended to the end of it. If the number of controls is low, that’s fine, just rename them.
Realistically though, to rename one item, takes between 5 seconds and 15+ seconds, depending on:
- How fast you type
- What naming scheme you have used for your controls
- How fast your internet connection is
(Yes, I’m serious – when you rename a control, the editor checks ALL the references in the App that reference it. It then saves that renamed control back up to the cloud file)
Here’s an example that took 10 seconds for one change.
This is a really tiny App with a single datasource and no references to any other objects within the App:
So, this means, 10 seconds for every control I am renaming in this Screen if I am doing it manually.
There’s 22 fields/columns, resulting in 110 controls, and 120 total controls in my small example Screen.
You likely have a form with DataCards in your App or multiple controls that perform a similar function. In a form, each DataCard by default has around 5 items (including DataCard itself). This can increase to 9 items if you are using Date/Time fields.
If the list or datasource you are using has 5 fields, that’s going to be 25 controls.
25 controls x 10 seconds
= 250 seconds
= approx 4.5 minutes (which is fine, I’d do this example manually)
Unfortunately, most Forms have around 30 to 60 fields depending on complexity, which means 150 to 300 controls.
This would work out to 1500 to 3000 seconds, which is 25-50 minutes (OMG!) solidly spent renaming controls.
(this is, of course, assuming you are a superhuman automaton who can do 300 control changes back-to-back without a delay between clicks and without stopping or breaks, perfectly, without any typos, while still maintaining your sanity)
That is crazy! What a waste of an hour! (more likely to be 1.5hours+ let’s be real)
“There is always a better way”
So, instead of doing this, we are going to do some wizardry to do bulk renaming of those duplicated Power Apps controls.
I should start the explanation of these steps by advising on nomenclature (naming) of controls and items. This should be done as you are building the App and is not only helpful to you when searching for items or when filtering using the searchbar, but also when renaming, or potentially when others have to edit your App.
The basic naming scheme I use is:
PLEASE CHOOSE A DESCRIPTIVE SCREEN NAME WHEN DECIDING ON YOUR SCREEN NAME
A screen name called Screen1 does not tell you anything about that screen!
For forms this expanded to:
Using this naming scheme, my screen name is on the end of the name, so when duplicating a whole screen your objects end with ScreenName_1
This is useful for the bulk-renaming process, but you could also have the screen name elsewhere in the name if you are happy to have a bunch of controls whose names have the new screen name but end in _1
Saving and Extracting the File
- Use Save As to download a local copy of your file.
- Use Windows’ in-built Zip, or 7zip (recommended for ease of use and as its open-source), or WinZip or whatever Zip program you have, to extract the contents of your .msapp file to a folder:
Opening and Replacing the relevant file contents
- Open the .json file in your preferred editor (I suggest Visual Studio Code) – This could also be Windows notepad, Microsoft Word, OpenOffice Writer etc.
DO NOT BE SCARED OF ITS SCARY-LOOKING CONTENT, THIS GUIDE DOES NOT REQUIRE YOU TO KNOW IT
If the duplicated screen was the last screen you created, it will be the LargestNumber.json file.
If it was not the last screen created before you saved, then you can open those .json files and look for your ScreenName_1, as the name of the screen is in the first line of code (in my case MenuScreen_1)
- Use a Search and Replace all function to find and replace your ScreenName_1 (in my case MenuScreen_1) with NewScreenName (in my case I will use SecondaryScreen)
- Save the file, and close it (I have just renamed 120 controls in 1 click by the way)
Building and Opening the edited App
- Right-click and Save-Link-as This msapp builder script from my github and save it to the extracted folder’s top level:
- Run the script (Right-click, Run with PowerShell)
- Enter the name that you want to call the file (ie in my case it will be Bulk Control Rename After, although this is just the name of the FILE, not of the App you will open). This creates a .msapp in that folder:
- Go to create.powerapps.com and Open > Browse for file and choose the .msapp file you just created
Boom! All controls in that screen are renamed!
Time is precious, and if you build multiple apps per week you are saving hours on your week and days on your year.
By using this method to do bulk renaming of duplicated Power Apps controls, which takes around 2 to 5 minutes, I have saved myself approximately 30 to 60 minutes of renaming just in this one screen!