1

enter image description here For Exm's insert token, is it possible to use OOTB contact facets? I.e. Personal_Title, Personal_Gender or only

$email$

$fullname$

$firstname$

$lastname$

$name$

$phone$

If this is the case, how can one implement the use of the OOTB facets?

2

The list that you included in your question is the full list of EXM ootb tokens. The list can be found here:

https://doc.sitecore.com/users/exm/90/email-experience-manager/en/insert-a-token-in-a-message.html

You cannot use any other facet data without custom coding.

If you want to add your custom tokens, you need to overwrite recipientPropertyTokenMap implementation (you can find it in Sitecore.EmailExperience.Core.config). All the details can be found in Sitecore documentation in Override the default token map section:

https://doc.sitecore.com/developers/exm/90/email-experience-manager/en/create-a-custom-personalization-token.html

In shortcut - update configuration with your custom map class:

<recipientPropertyTokenMap type="FooBar.CustomRecipientPropertyTokenMap, FooBar" singleInstance="true" />

And write your class inheriting from DefaultRecipientPropertyTokenMap:

namespace FooBar
{
    public class CustomRecipientPropertyTokenMap : DefaultRecipientPropertyTokenMap
    {
        protected static readonly MethodInfo GetMyFacetValue = 
            typeof(FacetExtensions).GetMethod(nameof(FacetExtensions.GetMyCustomFacetValue), new[] { typeof(MyCustomFacet) });

        static CustomRecipientPropertyTokenMap()
        {
            if (TokenBindings == null)
            {
                TokenBindings = new Dictionary<Token, RecipientPropertyTokenBinding>();
            }

            RecipientPropertyTokenBinding customTokenBinding = 
                RecipientPropertyTokenBinding.Build<MyCustomFacet>(new Token("customtokenkey"), null, GetMyFacetValue);
            TokenBindings.Add(customTokenBinding.Token, customTokenBinding);
        }
    }

    public static class FacetExtensions
      {
        public static string GetMyCustomFacetValue (this MyCustomFacet facet)
        {
          return facet.SomeProperty;
        }
    }
}

You also need to create a custom dispatch task so the values from other facets are also taken into account. It's explained in the article linked above. This step may not be necessary if you use on of the standard Sitecore facets as there is a chance they are already included by the default dispatch task.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.