カスタム パーソナライゼーション トークンのフォーム データを変換するパイプライン プロセッサーを作成する
概要
チェック ボックス リスト フィールドの値を変換し、コンマ区切り値のリストとして表示する新しいパイプライン プロセッサーを実装する方法。
顧客がサイトからフォームに入力して送信すると、自動メール キャンペーンを開始するように EXM を設定できます。ただし、元のフォーム フィールド値を別の形式に変換して、レンダリングされたメール メッセージでカスタム パーソナライゼーション トークンとして使用できます。
次の例では、パイプライン プロセッサーがチェック ボックス リスト フィールドの値を変換して、コンマ区切りの値のリストとしてレンダリングします。どのタイプのフォーム コントロールにも同じロジックを使用できます。
新しいパイプライン プロセッサーを実装するには:
CheckBoxListViewModel
フィールドをチェックし、フィールドの元の値をList<string>
からコンマ区切りの文字列に変換して、TransformedTokenValue
プロパティ値を設定するTransformCheckboxList
プロセッサーを実装します。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); } } }
Sitecore 設定にパッチを適用して、実装されたプロセッサーを
transformFormsCustomToken
パイプラインに含めます。<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:role="http://www.sitecore.net/xmlconfig/role/"> <sitecore role:require="Standalone or ContentDelivery"> <pipelines> <group groupName="exm.sendEmailSubmitAction"> <pipelines> <transformFormsCustomToken> <!-- 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" /> </transformFormsCustomToken> </pipelines> </group> </pipelines> </sitecore> </configuration>