Changing Flow action names, updating entity (schema) names, setting PCF properties… one script does it all

By | November 20, 2020

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:

image

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:

image

I could try renaming “List records” action, but I’d get an error if I tried saving the Flow after that:

image

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:

https://github.com/ashlega/ITAintBoring.PowerShell

image

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.

For example:

.\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:

image

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
  • Etc

 

Essentially, it’s a text replacement script. It just knows how to do that replacement in all solution components.

3 thoughts on “Changing Flow action names, updating entity (schema) names, setting PCF properties… one script does it all

  1. Danish N.

    Can it rename PCF control name or just properties? Also what about managed components can those be renamed too??

    Reply
    1. Alex Shlega Post author

      Hey Danish, in theory – yes. It’s essentially text replacement in the solution – will unpackage it and package back with the solution packager (could probably just zip/unzip, but just in case). Although, some components, such as Flow actions, may have more than one “representation” in the solution, so may need to play with that a little more, too (For the flows, it could be “Action name” for the display name and “Action_name” anywhere in the expressions). Btw, this script won’t work with the canvas apps, but, since all the code is already available in this XrmToolBox tool, guess it’s the next step to merge these two

      Reply
      1. Danish N.

        Very much like the idea of renaming as it will save so much time but I think we will have to be careful with the renaming. Again, bring the conversation from LinkedIn here about XTB maybe a tool that can provide a preview of the changes it will be doing. ?

        As the solution gets bulky with tons of different components it might be tricky to replace a string blindly without knowing the repercussion. For e.g. two flows have same action name but you only want to rename one of the flow right? But if developer is unaware of that it may cause issues especially in multi-developer environment.

        Reply

Leave a Reply

Your email address will not be published. Required fields are marked *