Flow / Power Automate - Add Conditional “Switch” Actions in Power Automate Tutorial

Learn how to create conditional 'switch' actions in Power Automate to generate sequences of actions based on specific cases. Avoid the nesting of multiple if conditional blocks and efficiently sort files into different folders based on their extension. Configure automated flows, isolate file extensions using Power FX language, and define specific actions for each case. Test and verify the functionality to ensure a seamless workflow. Explore this fully functional switch condition usage example now!

  • 03:58
  • 39 views

Objectifs :

This tutorial aims to guide users in creating a conditional switch action in SharePoint to automate file sorting based on file extensions. By the end of this tutorial, users will be able to set up an automated flow that efficiently organizes files into designated folders without the need for complex nested conditional blocks.


Chapitres :

  1. Introduction to Conditional Actions
    In this section, we will explore the concept of conditional actions, specifically the switch type, which allows for the generation of sequences of actions based on specific cases. This method simplifies the process by avoiding the nesting of multiple 'if' conditional blocks.
  2. Setting Up the Automated Flow
    To illustrate the use of a conditional switch, we will use the example of sorting files deposited in a team's folder based on their extensions. The goal is to sort files such as Word, Excel, and PowerPoint into their respective folders. Begin by configuring the automated flow using a SharePoint trigger that activates upon the creation of a file.
  3. Configuring SharePoint Trigger
    1. Select the target team and the relevant document library. 2. Limit the monitoring to a specific folder by checking the 'restrict to folder' option in the advanced settings. 3. Specify the concerned folder for file sorting.
  4. Isolating File Extensions
    To test the file extension, include a function in Power FX language that isolates the extension. Although another tutorial covers the basics of Power FX in more detail, you can find the message action in the predefined actions. In the data operation category, use the FX button to paste the isolation function.
  5. Retrieving File Metadata
    Next, retrieve the file's metadata, particularly the access path, which will be used to move the file. Specify the team containing the monitored folder and point to the deposited file to retrieve its metadata. Add dynamic content by identifying the file using the identifier field associated with it.
  6. Creating Conditional Switch Actions
    Now, generate actions based on the file type by adding an action from the control category and choosing the conditional switch action. The isolated file extension will allow you to process all specific cases. Test the element to be evaluated, which is the output of your message containing the file extension.
  7. Defining Actions for Each File Type
    1. Add a specific case for PowerPoint files (PTX) and a SharePoint file move action, specifying the site or team's address. 2. Reference the file dynamically by its path retrieved from the 'get file metadata' action and specify the destination, such as a subfolder named 'PowerPoint'. 3. Define the default action for files with the same name and set a move with a new name. 4. Repeat this procedure for each file type: XLX for Excel and DOCX for Word, renaming your cases for clarity.
  8. Handling Unmatched File Extensions
    For the default case, define actions if the file extension does not match any previously processed cases, for example, moving it to an 'others' folder.
  9. Finalizing the Flow
    Finally, add a message posting action to the team after the conditional block, which will execute regardless of the processed case. Specify that a file has been added to a specific folder using dynamic content. Save and test your flow.
  10. Testing the Flow
    Upload a file from Teams, such as a PowerPoint presentation, and verify that the file is moved to the correct folder and that the team message is posted accurately. Repeat the process with a PDF file to ensure the flow works perfectly.
  11. Conclusion
    This tutorial provides a comprehensive example of using a fully functional switch condition in SharePoint. By following these steps, users can automate file sorting efficiently, enhancing productivity and organization within their teams.

FAQ :

What is a conditional action in SharePoint?

A conditional action in SharePoint allows you to automate workflows by executing specific actions based on defined conditions, such as the type of file uploaded.

How do I create a switch type conditional action?

To create a switch type conditional action, you need to define the variable to evaluate, add specific cases for each possible value, and specify the actions to take for each case.

What are file extensions and why are they important?

File extensions are suffixes that indicate the file type, such as .docx for Word documents. They are important because they determine how files are handled and which applications can open them.

How can I test my automated flow in SharePoint?

You can test your automated flow by uploading a file to the specified folder and verifying that the file is processed correctly according to the defined actions, such as being moved to the appropriate folder.

What should I do if my flow doesn't work as expected?

If your flow doesn't work as expected, check the conditions and actions defined in your workflow, ensure that the file extensions are correctly specified, and review any error messages for troubleshooting.


Quelques cas d'usages :

Automating File Organization in Teams

In a corporate environment, a team can use a conditional action to automatically sort files uploaded to a shared folder based on their extensions. For example, PowerPoint presentations can be moved to a designated 'PowerPoint' folder, while Excel files are sorted into an 'Excel' folder, improving organization and accessibility.

Streamlining Document Management

A project manager can implement a switch type conditional action to manage project documents efficiently. By sorting files into specific folders based on their types, the team can easily locate necessary documents, enhancing productivity and reducing time spent searching for files.

Ensuring Compliance with File Types

In a regulated industry, a compliance officer can set up a flow that checks file extensions before allowing uploads. If a file type does not meet compliance standards, it can be automatically redirected to a review folder, ensuring that only approved file types are stored.

Improving Team Communication

After implementing a conditional action, a team can automatically post messages in a channel whenever a file is added to a specific folder. This keeps all team members informed about new documents and enhances collaboration.


Glossaire :

conditional action

An action that is executed based on specific conditions being met, allowing for dynamic decision-making in workflows.

switch type

A control structure that allows the execution of different actions based on the value of a variable, simplifying complex conditional logic.

file extension

The suffix at the end of a file name that indicates the file type, such as .docx for Word documents or .xlsx for Excel spreadsheets.

SharePoint

A web-based collaboration platform from Microsoft that integrates with Microsoft Office, used for storing, organizing, sharing, and accessing information.

Power FX

A low-code programming language used in Microsoft Power Platform to create custom logic and expressions.

metadata

Data that provides information about other data, such as the properties of a file, including its name, type, and access path.

dynamic content

Content that can change based on user input or other variables, often used in automated workflows to personalize messages or actions.

default action

An action that is executed when none of the specified conditions are met, serving as a fallback option.

00:00:07
which allows you to generate sequences of actions based on specific cases.
00:00:11
Thus avoiding the nesting of multiple if conditional blocks
00:00:16
to illustrate this.
00:00:17
Let's take the example of a file deposited in a team's team folder
00:00:21
which depending on its extension will need to be sorted into different folders,
00:00:25
word Excel, powerpoint, as well as in others folder
00:00:30
begin by configuring this automated flow using a SharePoint
00:00:34
trigger based on the creation of a file.
00:00:42
Select the target team as well as the relevant library.
00:00:47
In this specific case,
00:00:49
limit the monitoring to a specific folder by checking
00:00:52
the restrict to folder option in the advanced settings.
00:00:55
Then specify the concerned folder. In this example, file sorting
00:01:01
to test the file extension include a function
00:01:03
in power FX language that isolates this extension.
00:01:07
Another tutorial covers the basics of power FX in more detail.
00:01:11
But here look for the message action in the predefined actions.
00:01:14
Then in the data operation category,
00:01:17
use the FX button to paste the isolation function.
00:01:23
The next step is to retrieve the file's metadata,
00:01:26
particularly the access path which will be used in the process of moving the file.
00:01:32
Once the team's team containing the monitored folder is specified
00:01:35
point to the deposited file to retrieve the metadata.
00:01:38
To do this, add the dynamic content,
00:01:40
identifying the file using the identifier field associated with the file.
00:01:46
You can now generate your actions according to the file type by adding
00:01:50
an action from the control category and choosing the conditional switch action.
00:01:54
It is from the isolated file extension that you can process all specific cases.
00:02:00
Test the element to be evaluated,
00:02:01
which is the output of your message containing the file extension.
00:02:05
Then add a specific case for powerpoint files, PTX
00:02:11
and a SharePoint file move action
00:02:16
specifying the site or team's team address,
00:02:19
reference the file by its path dynamically
00:02:22
retrieved from the get file metadata action
00:02:24
specify the destination
00:02:27
here a sub folder named powerpoint.
00:02:30
In the same library,
00:02:31
you can also define the default action in case of a file
00:02:34
with the same name and set a move with a new name.
00:02:38
Repeat this procedure for each type of extension
00:02:41
XL X for Excel and doc X for word rename your
00:02:45
cases for clarity by changing the labels for each case,
00:02:48
add the file move action in the
00:02:50
same manner indicating the appropriate target folder
00:02:53
for the default case,
00:02:54
define the actions if the file extension does not match
00:02:58
any of the previously processed cases using for example,
00:03:01
in others folder,
00:03:03
finally add a team's message posting action after the conditional block,
00:03:07
which will execute regardless of the processed case
00:03:15
specify that a file has been added to a specific folder using the dynamic contents
00:03:27
save and test your flow.
00:03:30
Upload a file from teams, for example,
00:03:33
a powerpoint presentation and verify that the
00:03:35
file is properly moved to the right place
00:03:40
and that the team's message is correctly posted,
00:03:44
repeat with a PDF file to ensure your flow works perfectly. For all cases.
00:03:52
There, you have an example of a fully functional switch condition usage.

No elements match your search in this video....
Do another search or back to content !

 

Mandarine AI: CE QUI POURRAIT VOUS INTÉRESSER

Reminder

Show