3 Ways to Change the Trigger in Power Automate

Do you need to change the trigger in Power Automate? This post is going to show you how to change the trigger step in your Power Automate flow.

When you are first developing a flow, quite often you will start out by using a manual button trigger for ease of testing. Later, you might want to change this to a schedule or automated trigger.

For example, suppose you want to run the flow when an email arrives in an Outlook inbox and use various dynamic content from the trigger such as the subject line or email body.

You might create a manual button trigger with inputs for the subject and body then reference these in the flow. Then when the flow is built and tested, you will want to change the trigger.

This post is going to show you how to change the trigger as well as some tips to help build flows that avoid the common problem of disappearing trigger references when changing a trigger.

How to Change a Trigger

Here is a simple flow.

  1. It has a manual button trigger with a few input fields for the Subject and Body. These will be placeholders for the automated Outlook trigger while building and testing the flow.
  2. Here is an action that references the Subject input from the trigger as dynamic content.
  3. Here is an action that references the Body input from the trigger as dynamic content

Changing the trigger is very easy. All you need to do is delete the old trigger and then add a new trigger.

Follow these steps to change the trigger.

  1. Click on the Ellipse icon in the trigger step.
  2. Select Delete from the options.

This step and associated dynamic content will be deleted from this flow.

Power Automate warning
  1. Press the OK button. Power Automate warns you that you are about to delete the step and any dynamic content associated with it. This is necessary in order to delete the trigger.

This will remove the trigger, but also any dynamic content references to the trigger will be removed from your flow.

Since every flow needs a trigger step, the flow builder will prompt you to add another trigger. You can search or otherwise navigate to and select the new trigger for the flow.

You will need to look through your flow and replace any instance of the old dynamic content reference that has disappeared.

Unfortunately, in a large complex flow, this can be a daunting task. Power Automate won’t warn you a dynamic content reference is missing unless it was the only input in a required field of the step and you might miss adding back the new reference because of this.

But there are techniques to help you avoid this.

Export and Import Flow to Retain Trigger References

One method to easily replace a large number of trigger references is to change them directly in the JSON code for the flow.

The process will involve these steps.

  • Export the flow with the original trigger.
  • Change the Trigger and export the flow with the new trigger.
  • Open the definition.json file in the ZIP folders and copy and paste the actions JSON from the original export to the new export.
  • Import the modified ZIP file into Power Automate.

If you need to change any of the references, you can use a text editor and perform a find and replace across the entire action JSON to ensure the reference is changed everywhere.

Export the Flows

Select the flow and go to the Details screen. Click on Export and choose the Package (.zip) option from the menu.

Now you can change the trigger in the flow and then export the flow again.

💡 Tip: Make a copy of your flow and change the trigger in the copy.

This will create two exported versions of the flow. One with the original trigger and any references to the dynamic content intact, and another with the new trigger where all the references are removed.

The idea will be to copy and paste from the old export to the new export to return the dynamic content references.

Copy and Paste Action JSON

Open both definition.json files in the exported zip. You can open these in any text editor.

This is a JSON object that defines the flow and it includes a triggers and actions section which defines the trigger for the flow and any subsequent actions for the flow.

You can copy and paste the actions JSON from the original export to the new export with the updated trigger.

Import the Modified Flow ZIP

Now you can import the modified flow zip file.

Go to the My flows tab and click on the Import command then choose the Import Package option from the menu.

Copy Flow to Clipboard to Retain Trigger References

Exporting, modifying, and then importing the flow JSON definition can be tricky. Thankfully there is another option to achieve the same result.

You can copy and paste all the actions to the clipboard.

This will involve a few steps.

  • Add all the actions for the flow into a Scope action.
  • Copy the Scope action to the clipboard. You can then paste it into a text editor as an intermediate step to save the scope action.
  • Create a new flow with the desired trigger.
  • Paste the Scope action from the clipboard. This will add all the actions for the flow.

Add All Steps in a Scope action

The scope action is a way to group together steps. This also allows you to copy multiple steps in one go.

  1. Add a Scope action at the very top of the flow.
  2. Drag and drop each step into the Scope. You will need to add the actions starting from the top to the bottom of the flow so that any references to previous steps remain intact.

Copy the Scope to the Clipboard

  1. Click on the Ellipse icon in the Scope action.
  2. Select the Copy to my clipboard option from the menu.

💡 Tip: Press Ctrl + V in a text editor and this will paste the JSON of the scope action as text. You can then paste this in any flow.

Now you can create a new flow with the desired trigger and paste this Scope action from your clipboard to retain all the references.

Paste the Scope Action

Now paste the scope with all the action into a new flow.

  1. Add a new step to the flow.
  2. Click on the Clipboard tab.
  3. Select the Scope from the available items in the clipboard or press Ctrl + V to paste the JSON text.

Reference Content from the Trigger Indirectly

Changing the trigger can be a painful task, but if you plan ahead it won’t be so difficult!

The best plan is to create a compose action that references any dynamic content from your trigger and then reference that compose action for any subsequent steps.

This way you only need to update the references in one action no matter how many times they are references in the subsequent steps.

{
"triggerEmailSubject": "@{triggerBody()['text']}",
"triggerEmailBody": "@{triggerBody()['text_1']}"
}
  1. Add a Compose action as the very first step in your flow. This is where you can create a JSON object similar to the above that contains all the trigger content that your flow will reference.

This sets up a JSON object with key-value pairs where the value can be referenced anywhere else in the flow using the key. This is a comma-separated list of keys (or field names) with the associated value from the trigger dynamic content inside a pair of curly braces {}.

When you replace the trigger, you will only have to replace these dynamic content blocks in the flow. This will be much easier than searching through the entire flow and adding them back.

@{outputs('Trigger_Content')['triggerEmailSubject']}

You can then reference any of the values using the above expression where Trigger_Content is the name of the Compose action and triggerEmailSubject is the name of the key you created in the compose action.

These references won’t disappear when you change the trigger!

Conclusions

Changing the trigger is a very common practice when building and testing a flow.

This requires deleting the existing trigger and creating a new one.

Unfortunately, this means you’ll need to add back any references to the old trigger since they get automatically removed when you delete a trigger.

You can do this either with the exported JSON or using the clipboard feature from a Scope action.

The best option is to plan ahead though and indirectly reference your trigger content to avoid the headache in the first place!

Did you find these techniques useful? Do you know any other methods to easily replace lost dynamic content in flow? Let me know in the comments!

About the Author

John MacDougall

John MacDougall

John is a Microsoft MVP and freelance consultant and trainer specializing in Excel, Power BI, Power Automate, Power Apps and SharePoint. You can find other interesting articles from John on his blog or YouTube channel.

Related Articles

Comments

0 Comments

Get the Latest Tech Tips

Write For Us

Are you a tech enthusiast with a talent for writing great content? Come write for us!

Follow Us

Follow us on social media to stay up to date with the latest in tech!