Create a pipeline processor to convert form data in a custom personalization token

Current version: 10.0

You can set up EXM to initiate an automated email campaign once the customer has completed and submitted a form from a site. However, you might want to transform the original form field value to a different format for use as a custom personalization token in the rendered email message.

In the following example, the pipeline processor transforms the value of a check box list field and renders it as a list of comma-separated values. You can use the same logic for any type of form control.

To implement a new pipeline processor:

  1. Implement a TransformCheckboxList processor that checks for the CheckBoxListViewModel field and transforms the original value of the field from a List<string> to a comma-separated string and sets the TransformedTokenValue property value:

    public class TransformCheckboxList : Sitecore.EmailCampaign.Cd.Pipelines.TransformFormsCustomToken.ITransformFormsCustomTokenProcessor
            public void Process(Sitecore.EmailCampaign.Cd.Pipelines.TransformFormsCustomToken.TransformFormsCustomTokenArgs args)
                if (args == null)
                    throw new ArgumentException();
                if (args.Field is Sitecore.ExperienceForms.Mvc.Models.Fields.CheckBoxListViewModel checkBoxListViewModel)
                    List<string> checkboxListValues = checkBoxListViewModel.Value;
                    args.TransformedTokenValue = string.Join(", ", checkboxListValues);
  2. Patch the Sitecore configuration to include the processor implemented in the transformFormsCustomToken pipeline:

     	<configuration xmlns:patch="" xmlns:role="">
        <sitecore role:require="Standalone or ContentDelivery">
                <group groupName="exm.sendEmailSubmitAction">
                            <!-- Transforms the checkbox list field value from a List<string> to a comma separated string -->
                            <processor type="Sitecore.EmailCampaign.Samples.FormsIntegration.Pipelines.TransformFormsCustomToken.TransformCheckboxList, Sitecore.EmailCampaign.Samples.FormsIntegration" />

Do you have some feedback for us?

If you have suggestions for improving this article,