Every now and then, we need to change Flow action names. This usually happens to me once the Flow has already been somewhat developed and I have a bunch of actions which have very meaningful names:
It helps to know that there are 3 list record actions in the Flow above. But it does not tell me anything about what those actions are doing.
What if I wanted to rename some of them?
This is not always straightforward. There could be other actions utilizing those I’m trying to rename – for some of those, Power Automate flow designer will be able to update the dependencies. But, for others, it may become more involved. For example, let’s say I had a flow like this:
I could try renaming “List records” action, but I’d get an error if I tried saving the Flow after that:
Which is an actionable error – I can go ahead and make required changes in the other actions. If those dependent actions are spread across the Flow, though (various conditions, for example), it may become quite a bit more involved.
So, if there comes a point where you’d want to have some scripting help in this situation, here is a Power Shell script that might help:
This script will take a solution file, a regular expression, a replacement string (to replace matching substrings in all solution components), and an output solution file.
.\psreplace.ps1 -solutionPath “c:\work\temp\psreplace\ources\FlowActionNameChange_1_0_0_1.zip” -regex “List records” -replaceWith “Get records” -outputSolutionPath “c:\work\temp\psreplace\sources\UPDATEDFlowActionNameChange_1_0_0_1.zip”
You can output to the same file you used for the input. In the above example, you will also need to replace “List_records” with “Get_records”, so you’d probably have to run the same script twice, and, for the second run, you might use the following command:
.\psreplace.ps1 -solutionPath “c:\work\temp\psreplace\sources\UPDATEDFlowActionNameChange_1_0_0_1.zip” -regex “List_records” -replaceWith “Get_records” -outputSolutionPath “c:\work\temp\psreplace\sources\UPDATEDFlowActionNameChange_1_0_0_1.zip”
The first time this script starts, it will download nuget and use it do deploy SolutionPackager into the PSModules\Tools\CoreTools subfolder. After that, it’ll be using the same copy of the solution packager.
For instance, with the command lines above, here is how it’s going to work:
Once that updated solution is imported, the Flow above gets updated and the action with all its references is named differently now:
So what else can you use this script for?
- Rename entities in the solution
- Update view names
- Update PCF control properties to match the environment
Essentially, it’s a text replacement script. It just knows how to do that replacement in all solution components.