Example: Using the Switch Action
Suppose you have a requirement where, whenever a new file is uploaded to a OneDrive account from some vendor, that file is downloaded and is sent as an attachment through email to a client. However, due to some download restrictions, if the file size is greater than the specified limit, a download file URL is sent through email instead of attaching the file. For this use case, the workflow would consist of the following actions:
Step 1: Add and configure the OneDrive trigger
The following steps provide details of the values that you need to specify in the action form for this specific example. For detailed steps on configuring this trigger, see OneDrive Triggers.
1. In the Select Trigger list, select New File.
Step 2: Configure the Switch action
The following steps provide details of the values that you need to specify in the action form for this specific example. For detailed steps on configuring this action, see Switch.
Define the following conditions in the Switch action:
If the size of the uploaded file exceeds 1 MB, then a download file URL is sent over mail.
If the size of the uploaded file is less than 1 MB, then the file is downloaded and sent as an attachment in an email.
1. Drag the Download File and Switch actions under Developer Tools and two Send an Email actions under Office 365 to the canvas.
2. Modify the Label of the Send an Email actions to the following:
Send file URL over Email
Attach File to Mail
3. In the Switch action, define the condition to check if the file size is greater than 1024 bytes, and specify the action to be executed if the specified condition is met.
a. In the Input field, map the value of Size under the OneDrive Trigger Data section.
b. In the Condition list, select (Number) Greater Than.
c. In the Expected field, enter 1024.
d. In the Select Action list, select the Send file URL over Email action. This action is executed if the specified condition is met.
It automatically fetches all available actions on the canvas and displays it in the list.
4. Under the Default section, in the Select Action list, select the Attach File to Mail action. This action is executed if the specified condition is not met.
5. Click Done.
ThingWorx Flow automatically connects the Switch action with the actions specified in the Switch configuration window; thus creating different paths for each case stating the case numbers.
Step 3: Configure the Download File action under Developer Tools
The following steps provide details of the values that you need to specify in the action form for this specific example. For detailed steps on configuring this action, see Download File.
1. In the URL field, map the value of Download URL from the OneDrive trigger data.
2. In the Name of the Downloaded File field, map the value of Name from the OneDrive trigger data.
3. Connect the Download File action to the Attach File to Mail Send an Email action.
Step 4: Configure the (Attach File to Mail) Send an Email action under Office 365 to send an attachment through email
The following steps provide details of the values that you need to specify in the action form for this specific example. For detailed steps on configuring this action, see Send an Email.
1. Under Attachments, in the Source File Path field, map the value of File/Folder Path parameter from the Download File action.
Step 5: Configure the (Send file URL over Email) Send an Email action under Office 365 to send file URL through email
The following steps provide details of the values that you need to specify in the action form for this specific example. For detailed steps on configuring this action, see Send an Email.
1. In the Body field, map the value of Download URL from the OneDrive trigger data.
Was this helpful?