How to enable queries in Sitecore Rendering Data Sources
Allow the use of queries in Rendering Data Sources.
Then I added a Save Action to send an email.
Here’s what I ended up with for the email body text. Note that there’s a [Referral]
token in there, despite there not being a Referral
field on the form.
I chose to do this using a ProcessMessage pipeline, which is one of the ones provided by WFFM.
First I added a new processor.
using Sitecore.WFFM.Abstractions.Mail;
namespace MyAssembly
{
public class ProcessMessage
{
public void AddCustomData(ProcessMessageArgs args)
{
var sidValue = HttpContext.Current.Session["some-key"] ?? "";
args.Mail.Replace("[Referral]", sidValue.ToString());
}
}
}
It is configured using a patch config file in the App_Config\Include
folder like this. Note that it’s patched in before the SendEmail
processor.
<?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<pipelines>
<processMessage>
<processor patch:before="processor[@method='SendEmail']" type="MyAssembly.ProcessMessage, MyAssembly" method="AddCustomData" />
</processMessage>
</pipelines>
</sitecore>
</configuration>
Hey presto. Done!