Text Actions in Power Automate Desktop

 Text Actions in Power Automate Desktop

In Power Automate Desktop, Text Actions are actions that allow you to manipulate and work with text. Whether you need to extract a part of a string, replace words, or even check if certain text exists, Text Actions make it easy to automate all sorts of tasks involving text data.

These actions can help you perform things like:

  • Extracting data from an email subject or body.
  • Searching for specific words in a document.
  • Splitting long text into smaller chunks.
  • Replacing certain words or characters in a string.
  • Checking if a string contains a specific word.

Think of Text Actions as your toolkit for handling text. Just like how you would use scissors to cut paper, in PAD, you use text actions to cut, paste, and transform text to fit your needs.




Common Text Actions in Power Automate Desktop

There are many different Text Actions available in Power Automate Desktop, and each one is useful for different tasks. Let’s go through some of the most commonly used text actions and what they do:

1. Set Text Variable

This action allows you to create a text variable and assign it a value (a string of text). You can use it to store a sentence, a name, or any other piece of text.

Example:

You can create a text variable called StudentName and set its value to "John Doe". Later in the flow, you can use this text variable in different actions, like sending an email or printing it on the screen.

  • Action: Set Text Variable
  • Variable: StudentName
  • Value: "John Doe"

2. Text Contains

This action allows you to check if a specific word or phrase exists in a given text. It’s really useful when you want to search for something and take action based on whether it’s found.

Example:

Let’s say you receive an email with the subject “Homework Reminder.” You can use the Text Contains action to check if the email subject contains the word “Homework”. If it does, you can trigger an action, like sending a reminder or marking the email as important.

  • Action: Text Contains
  • Text: "Homework Reminder"
  • Check if Contains: "Homework"
  • Result: True (if the word is found)

3. Replace Text

With this action, you can replace part of a text string with something else. This is really helpful if you need to edit or update certain parts of a string. For example, changing a date format or updating an email template.

Example:

Suppose you have the string "Your appointment is scheduled for 10 AM" and you want to change "10 AM" to "2 PM". You can use the Replace Text action to automatically make this change.

  • Action: Replace Text
  • Text to Replace: "10 AM"
  • Replace with: "2 PM"
  • Result: "Your appointment is scheduled for 2 PM"

4. Substring

The Substring action allows you to extract a part of a string of text. You can specify where the substring starts and how many characters you want to extract.

Example:

Let’s say you have the following string: "2024-11-11: Project due". If you want to extract the date part from this string, you can use the Substring action to grab the first 10 characters.

  • Action: Substring
  • Text: "2024-11-11: Project due"
  • Start Index: 0 (this is where the substring starts)
  • Length: 10 (this is how many characters you want to extract)
  • Result: "2024-11-11"

5. Split Text

The Split Text action lets you break down a string into multiple pieces, based on a separator (like a comma, space, or special character). This is really useful when you have a list of items in one text string, and you want to separate them into individual parts.

Example:

Imagine you have a text string like this: "John, Emma, Chris, Sophia". If you want to split the names into separate items, you can use Split Text.

  • Action: Split Text
  • Text: "John, Emma, Chris, Sophia"
  • Separator: ", " (a comma followed by a space)
  • Result: A list of items: ["John", "Emma", "Chris", "Sophia"]

6. Trim Text

The Trim Text action removes extra spaces (leading and trailing) from a string. This is helpful when you're working with data that might have unwanted spaces at the beginning or end.

Example:

Let’s say you have the string " Hello World! " with spaces before and after the text. Using the Trim Text action will remove those extra spaces.

  • Action: Trim Text
  • Text: " Hello World! "
  • Result: "Hello World!"

Key Differences Between Text Actions

Now that we’ve looked at some of the common Text Actions, let’s compare them to understand when and how to use each one. Here's a simple table to help you see the differences:

ActionWhat It DoesUse When
Set Text VariableSets a value for a text variable.Use when you need to create or update a text variable.
Text ContainsChecks if a specific word or phrase exists in the text.Use when you need to search for a specific word or phrase in a string.
Replace TextReplaces a part of the text with something else.Use when you need to change or update certain parts of a string.
SubstringExtracts a portion of the text from a string.Use when you need to grab a specific part of a string (like a date or time).
Split TextBreaks down a string into multiple pieces.Use when you need to split a string into parts, like a list of items.
Trim TextRemoves leading and trailing spaces from the text.Use when you want to remove unwanted spaces from the start or end of a string.

Real-Life Example Using Text Actions

Let’s say you receive a list of students’ names and grades in a single string: "John: A, Emma: B, Chris: C, Sophia: B". You want to extract just the names and the grades into separate lists and send a reminder to students who got grade B.

Here’s how you can do that:

  1. Action 1: Use the Split Text action to split the string by ", ", creating a list of "John: A", "Emma: B", etc.
  2. Action 2: Use a For Each loop to go through each item in the list.
  3. Action 3: Use the Text Contains action to check if the grade is "B".
  4. Action 4: If the grade is "B", send a reminder email to that student.

Conclusion

Text Actions in Power Automate Desktop are super useful for automating tasks that involve working with text. Whether you’re looking to extract specific information, replace words, or simply clean up data, these actions can save you a lot of time and effort.

Here’s a quick summary of what we covered:

  • Text Actions help you manipulate, extract, and work with text in your automation flows.
  • Some of the most common actions are Set Text Variable, Text Contains, Replace Text, Substring, Split Text, and Trim Text.
  • Each action has its own purpose, depending on what you need to do with the text.

I hope this helps you get started with Text Actions in Power Automate Desktop. Feel free to experiment with these actions in your own flows, and you’ll be automating text-related tasks in no time!

Happy automating! 😊