Insert excerpt | ||||||||
---|---|---|---|---|---|---|---|---|
|
What is an Email Action?
Insert excerpt | ||||||
---|---|---|---|---|---|---|
|
The Email action can be used to send one or multiple emails. If 100 records are pushed into the Actionflow then 100 emails will be sent, unless a phase is used to send a single email.
Creating Email Actions
- Click and drag the
icon from the toolbar onto the canvasInsert excerpt _action_email _action_email nopanel true - Enter a name for the Email action, then select Create Action
- In the Email action on the right, populate the following details: Properties
Tip |
---|
All fields can be either literal values or expressions encapsulated within ${} syntax, for example |
Field | Description | Example | |||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Name | Name given to the Email Node. This will be displayed on the Actionflow canvas. | MyEmailer | |||||||||||||||||||||||||||||||||||
From | The email address the email will be sent from. This should match the email address specified as the login email in your Outbound Emailer.
| notifications@phixflow.com | |||||||||||||||||||||||||||||||||||
To | The email address(es) the email will be sent to. Multiple addresses must be comma separated, if an expression evaluates to a list of email addresses then this will be converted automatically to the correct format. This accepts JEP expressions in the format ${Connector.AttributeName} | or
| |||||||||||||||||||||||||||||||||||
CC | The CC email addresses. Provided as a comma-separated list if multiple values are required. If an expression evaluates to a list then this will be converted automatically to the correct format. This is an optional field. | info@phixflow.com, marketing@phixflow.com | |||||||||||||||||||||||||||||||||||
BCC | The BCC email addresses. Provided as a comma-separated list if multiple values are required. If an expression evaluates to a list then this will be converted automatically to the correct format. This is an optional field. | info@phixflow.com, marketing@phixflow.com | |||||||||||||||||||||||||||||||||||
Subject | The email's subject. This accepts JEP expressions in the format ${Connector.AttributeName} and ${Function}. | // Send the message followed by a timestamp MyEmailer has run successsfully at ${now()} | |||||||||||||||||||||||||||||||||||
is HTML |
The default setting is plain text. This accepts JEP expressions in the format ${Connector.AttributeName} and ${Function}. | ||||||||||||||||||||||||||||||||||||
Message | The content of the email. This can be text or JEP expressions. | // Sends the content of the attribute MyMessage from the in pipe ${in.MyMessage} |
${in.MyValue}
. ${} |
Verifying Emails
It is possible to check an email has successfully been sent using the Email tab at the top of the system console. System Console → Email Tab. See System Console
Attachments
Sending emails with attachments is possible in PhixFlow but not yet supported in Actionflows. To send an email with an attachment, see Sending Emails.
Built-in Error Handling
Basic validation is performed to ensure that email addresses are well-formed. If they are not this will cause the Actionflow to fail immediately. Other errors, such as email addresses for accounts that don’t exist, won’t cause a failure of the Actionflow but they will result in an unsuccessful email send.
Opening an Email Client
The
Insert excerpt | ||||||
---|---|---|---|---|---|---|
|
Expand | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
|
HTML Comment | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
|
Worked Examples
Here are worked examples using the Retail Data (available from the Learning Centre).
In this example, we are using:
- A Shop Staff Form screen containing blank input fields, set up to create a new staff member - this screen was created using the Edit Form template
- A Shop Orders screen containing a grid of the Shop Orders data, Order Status filters buttons and a card container of the Shop Order Lines data - this screen was created using the Multi-Tile template
Tip |
---|
If you are completing this chapter as part of the Actionflow course and using a training instance, the data and screens have already been pre-loaded into the Actionflow Intermediate Application. For these example, we'll be working on the Save button on the Shop Staff Form, and creating a button on the Shop Orders screen. |
Example 1: Send One Email For One Record
In this example, we'll modify the Actionflow on the Save button of the Shop Staff Form. We'll configure this Actionflow to send an email to the Team Leader (i.e. you) with a reminder to complete a full induction.
- On the Shop Staff Form screen, open the Actionflow on the Save button
Create a new
action to ensure an email is only sent when a new employee is saved but not when an existing employee is saved, and insert this between theInsert excerpt _action_gateway _action_gateway nopanel true
node andInsert excerpt _input _input nopanel true
actionInsert excerpt _action_save _action_save nopanel true Expand title How? - Ensure that staffID is mapped into the Gateway action from the input
- Click on the Save action on the canvas and rename this to:
Save NEW Staff
- Ensure Auto Save Attributes is toggled on and change the Type to Insert
- Create an additional Save action and name it:
Save EXISTING Staff
- Ensure Auto Save Attributes is toggled on and change the Type to Update
- Hover over the Gateway action
- Map the SaveOnly connector to the Save EXISTING Staff action
- Map the SaveAndEmail connector to the Save NEW Staff action
- You should now have a Gateway action, followed by two Save actions, with the attribute staffID mapped to both
- Hover over the Save NEW Staff action on the canvas and select, out
Click onto any blank canvas space and choose the
iconInsert excerpt _action_email _action_email name icon nopanel true - Enter a suitable name for the node and select Create Action
- Map across the staffID attribute from the table to the Email action
- Click on the input connection point, under Connections, and map in the following attributes:
- departmentID
- departmentName
- employmentType
- first_name
- last_name
- startDate
Then map these attributes into the Email action
Expand title Checkpoint
Email Action Setup
- Click on the Email Action to open its Properties and pin the tab
- For the From field, we need to use the email address specified as the login email in your Outbound Emailer; to find this, in the
, expandInsert excerpt _repository _repository name full nopanel true Insert excerpt _emailConfiguration _emailConfiguration name accounts nopanel true - Double-click on
Outbound emailer and copy the login emailInsert excerpt _emailConfiguration _emailConfiguration name icon nopanel true
- Double-click on
- Paste this into the From field on your pinned
properties, and enter the following:Insert excerpt _action_email _action_email nopanel true - To:
enter your email address
- This way you can see if the Actionflow is working
Subject:
Code Block language js theme Emacs New Employee: ${in.first_name} ${in.last_name}
- is HTML: Toggle on
Insert excerpt _toggle_on _toggle_on nopanel true Message:
Code Block language js theme Emacs Hello ${_user.name}, You have a new team member! Here are ${in.first_name} ${in.last_name}'s details: ID Number: ${in.staffID} Start Date: ${toString(in.startDate, "dd MMMM yyyy")} Department: ${in.departmentID} ${in.departmentName} Contract Type: ${in.employmentType} Please ensure ${in.first_name} ${in.last_name} completes their full induction training and all training sign offs are completed by ${toString(dateAdd(in.startDate,_WEEK_OF_YEAR, 2), "dd MM yyyy")}.
- Leave all other fields blank
Insert excerpt _finish _finish nopanel true Expand title Checkpoint
- To:
Testing
- To test the Actionflow:
- Create a new staff member using the Staff Form and if you provided your own email in the To field, you will receive the email you set up above
- Update an existing staff member and after saving, you should not receive an email
Example 2: Send One Email For Multiple Records
In this example, we'll configure a button to run a processing check of all order lines for all incomplete orders. This will check for any incomplete orders where all order lines are marked as 'Closed'. Where an order's order lines are all closed, the order will be updated to Completed and an email will be sent detailing how many orders have been updated to Completed that day.
In an Actionflow, to send one email for multiple records, an additional
Insert excerpt | ||||||
---|---|---|---|---|---|---|
|
Setup the Views and Calculate Action
- On the Shop Orders screen, use the palette to create a button that will initiate the Actionflow
- Right-click on the button and
Insert excerpt _actionflow_add _actionflow_add nopanel true - On the Actionflow canvas, configure an Input of On Click
Add a
Action and set the Primary Table to the Orders dataInsert excerpt _action_view _action_view nopanel true Filter on the View Action to only retrieve the incomplete orders
Expand title How? Add a Filter with the filter conditions:
- Status not equals
Completed
Add Output Attributes:
- orderID
- status
For more help on using View actions, see 1.15 View Action Configuration.
- Status not equals
- Remember to save the View Action properties which will display with a * if unsaved
Connect the input to this View Action
Add a
Action from the toolbarInsert excerpt _action_calculate _action_calculate nopanel true This Calculate Action will be to used to change the order status
Connect the View Action to the Calculate Action
Map across the attributes orderID and status
Expand title Checkpoint Add another
Action from the toolbar to the canvas and set the Primary Table to the Order Lines dataInsert excerpt _action_view _action_view nopanel true - Hover over the Calculate Action and choose Add Lookup, and give the lookup a suitable name, e.g.
ORD
, then click on the View action you just created - Click on the View action node and set the Output Attributes:
- lineStatus
- orderID
- orderLineID
- orderLineNumber
- Filter on the View Action to only retrieve Open order lines, and where the orderID from the Orders data equals the orderID from the Order Lines data
Expand title How? Add a Filter with two filter conditions:
- Where ALL of the following are true:
- lineStatus not equals
Closed
- The field should be interpreted as an Literal value
- orderID equals
orderID
- The field should be interpreted as an Expression
- The field should be interpreted as an Expression
- lineStatus not equals
Expand title Checkpoint - Where ALL of the following are true:
- Click on the lookup connector to configure the Incoming Mappings:
- Map across orderID
- Configure the Outgoing Mappings:
- lineStatus
- orderID
- Click on the Calculate Action and using the function countElements, add two Output Attributes:
- add an Output Attribute that will be used to modify the order's Status. The expression should count the records coming from the lookup. Where this is more than zero, return the order's status. Where this is zero, return the string, "Completed"
- zero records means that all Order Lines are Closed
- the "Completed" string will be mapped to the Order Status
add an Output Attribute that will be used to modify the order's Completion Date. The expression should count the records coming from the lookup and where this is more than zero, return NULL but where this is zero, return today's date
Expand title How? Add an Output Attribute for the status:
Code Block theme Emacs title StatusOutputAttribute if( countElements(ORD) > 0, in.status, //flag record as Completed if all order lines Closed "Completed" )
Add an Output Attribute for the completion date:
Code Block theme Emacs title CompletionDateOutputAttribute if( countElements(ORD) > 0, _NULL, //return today's date for complete orders now() )
- add an Output Attribute that will be used to modify the order's Status. The expression should count the records coming from the lookup. Where this is more than zero, return the order's status. Where this is zero, return the string, "Completed"
- Add a
Action to the canvas that saves data back to the Orders datasetInsert excerpt _action_save _action_save nopanel true - Connect the Calculate action to this Save action, and map across:
- The StatusOutputAttribute onto the status in the data
- The CompletionDateOutputAttribute onto the completionDate in the data
- The orderID from the Orders View onto the orderID in the data
Change the Type to Update in the Save Action Properties
Expand title Checkpoint
Setup the Email Phase
Create an additional phase in the Actionflow to send an email in. This is required to ensure only one email is sent regardless of the amount of records passing through the Actionflow.
As data cannot be passed between phases, the emailing phase will include a lookup to the Orders data, specifically to the data that was saved as part of the first phase of the Actionflow.
- Add a
to the canvas and create an additional phase to send the email inInsert excerpt _action_phase _action_phase name start nopanel true - Connect the Save action to the Start Phase action
- Open the Emailing Phase and configure an Input of On Phase Start
- Add a
Action that will be used to count records coming from a lookupInsert excerpt _action_calculate _action_calculate nopanel true - Connect the input to the Calculate Action
- Add a
Action with the Orders data as the Primary TableInsert excerpt _action_view _action_view nopanel true - Filter on the View Action to only retrieve Orders with a Completion Date of today
Expand title How? Add a Filter with the filter condition:
- CompletionDate equals
today()
- CompletionDate equals
- Filter on the View Action to only retrieve Orders with a Completion Date of today
- Hover over the Calculate Action and choose Add Lookup, then click on the View action you made above
- On the Output Attributes section of the View action, drag and drop the attributes completionDate and orderID
- Click on the lookup connector to map the Outgoing Mappings:
- completionDate
- orderID
Click on the Calculate Action and using the function countElements, add an Output Attribute that simply counts the records coming from the lookup connector
Expand title How? Add an Output Attribute:
- Type: Integer
Expression:
Code Block theme Emacs countElements(lu)
- Add a
Action to the canvas and connect the Calculate Action to thisInsert excerpt _action_email _action_email nopanel true - Map across the above Output Attribute from the Calculate action to the Email action
- Click on the Email Action to open its Properties, and enter the following:
- From: use the email address you used in Example 1
- To:
enter your email address
- This way you can see if the Actionflow is working
Subject:
Code Block language js theme Emacs Order Completion Check
- is HTML: Toggle off
Insert excerpt _toggle_off _toggle_off nopanel true Message:
Code Block language js theme Emacs Overnight order processing run finished at ${toString(now(),"dd MM yyyy, HH:mm:ss")}. ${in.YourOutputAttribute} order(s) now completed.
- Ensure you modify the above code with the name of your Output Attribute
- Leave all other fields blank
Insert excerpt _finish _finish nopanel true Expand title Checkpoint
Test the Actionflow
To test the Actionflow we need an Open or Processing order that has all of its order lines set to Status of Closed.
- On the Shop Orders screen, use the filters to find an Open or Processing order
- Choose an Order and change all of its Order Lines to Closed and Save each change
- Click on the button you created on the screen to initiate the Actionflow