2

Getting the following error on EXM log when submitting a form with Send Email with Exm submit step using Sitecore FormsExtensions sc10.1-4.0.2 on Sitecore 10.2.0

Exception: System.NullReferenceException
Message: Object reference not set to an instance of an object.
Source: Feature.FormsExtensions
   at Feature.FormsExtensions.SubmitActions.SendEmail.Tokens.MailTokenBuilder.BuildTokens(IDictionary`2 fieldTokens, FormSubmitContext formSubmitContext)
   at Feature.FormsExtensions.SubmitActions.SendEmail.SendEmailBase`1.BuildCustomTokens(T data, FormSubmitContext formSubmitContext)
   at Feature.FormsExtensions.SubmitActions.SendEmail.SendEmailExtended.BuildCustomTokens(SendEmailExtendedData data, FormSubmitContext formSubmitContext)
   at Feature.FormsExtensions.SubmitActions.SendEmail.SendEmailBase`1.Execute(T data, FormSubmitContext formSubmitContext)

User sees this on the front-end:

enter image description here

Things I have tried without resolve:

  1. Republish everything under sitecore/content/email tree
  2. Reindex sitecore/content/email and sitecore/forms trees
  3. republish the whole site
  4. Reinstalling the Sitecore FormsExtensions sc10.1-4.0.2

The workaround has been to change the email message attached to this step, publish form. Come back and assign it the previous message and publish again. Form successfully submits.

I'm assuming the field tokens are null - what are field tokens? Any hints on what could cause this issue?

2 Answers 2

1

Is this after an upgrade perhaps? The FormsExtensions work quite differently for emails in the latest version.

Anyway, what you should verify in any case:

  • on the form in the submit action make sure the tokens section is filled correctly:
    • the all fields token checkbox must be checked if you want to work with the $AllFormFields$ token
    • for each field you want as a token, you must add the token_name and form field
  • in the email, you can use tokens like $form_first_name$ (or the $AllFormFields$ if that was checked)

enter image description here

1
  • This was it! Yes, the issues started happening after the upgrade. Thank you.
    – gjakovaime
    Mar 10 at 17:56
1

The Email Experience Manager (EXM) supports tokens that you can use to personalize your email campaign messages. For example, in the beginning of a message, you can use the token $name$ in the greeting so that when you send your email campaign, the token is replaced with the name of the contact.

Note: If the name of the contact is not available, the recipient sees the actual token.

The following tokens are by default available in EXM:

  1. $email$
  2. $fullname$
  3. $firstname$
  4. $lastname$
  5. $name$
  6. $phone$

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

You can try this to resolve the token.

Default EXM tokens should be resolved by default in web version of email. If not, then check sc_pd_view=1 is appended as query string to the URL.

https://domain.com/?sc_itemid=%7bEmail_Message_GUID%7d&sc_lang=en&sc_pd_view=1

To append this parameter, you can check your email template view file, Link should create like this

If you are unable to view this message correctly,
<a href="/[email protected]&[email protected]&@GlobalSettings.OnlineVersionQueryStringKey=1">
                           click here to view online.
                       </a>

credit: https://sitecorewithraman.wordpress.com/2021/01/10/sitecore-exm-custom-tokens/

Refer to this for more details: https://sitecorescientist.com/2018/11/19/sitecore-9-forms-part-3-send-exm-e-mail-submit-action/

Hope it helps!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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