Thursday, 10 November 2016

Sitecore WFFM not sending emails

Some weeks ago, I had an issue with the Sitecore Web Forms For Marketers (WFFM) module related to the Save Actions and sending out Email messages. All the data collection was handled in MongoDB correctly, but in some of the forms no emails was send.

When the WFFM did not send out email messages, I found the following exception message in the log file:

"Exception: System.NullReferenceException
Message: Object reference not set to an instance of an object.
Source: Sitecore.Forms.Core
at Sitecore.Form.UI.Adapters.ListControlAdapter.AdaptToFriendlyListValues(FieldItem field, String value, Boolean returnTexts)
at Sitecore.Form.UI.Adapters.ListControlAdapter.AdaptToFriendlyValue(FieldItem field, String value)
at Sitecore.Form.Core.Utility.FieldReflectionUtil.GetAdaptedValue(FieldItem field, String value)
at Sitecore.Form.Core.Pipelines.ProcessMessage.ProcessMessage.ExpandTokens(ProcessMessageArgs args)
at (Object , Object[] )
at Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args)
at Sitecore.Form.Core.Submit.SubmitActionManager.ExecuteSaving(ID formID, ControlResult[] list, ActionDefinition[] actions, Boolean simpleAdapt, ID sessionID)"

Taking a look at the exception it shows some problems with the AdaptToFiendlyListValues method. So I knew it had something to do with List fields types. 

Looking at one of the WFFM List field item at a WFFM form the list data was stored in the “Localized Parameters” field. It seemed all good and fine:

  • %3cquery+t%3d%22default%22+sov%3d%22true%22%3e%3cvalue%3eyes%3c%2fvalue%3e%3c%2fquery%3e%3cquery+t%3d%22default%22+sov%3d%22true%22%3e%3cvalue%3eno%3c%2fvalue%3e%3c%2fquery%3e

Reflecting the “Sitecore.Form.UI.Adapters.ListControlAdapter.AdaptToFriendlyListValues” in Sitecore.Forms.Core.dll:

The Regex.Match in line 21 expect a decoded value – but the value stored in the “Localized Parameters” field was encoded.

Decoding and saving the value stored in the “Localized Parameters” field of the List field item, the value would be:

  • "<items><query sov="true" t="default"><value>yes</value></query><query sov="true" t="default"><value>no</value></query></items>"

The form could now send out emails regarding the field types.

I created a Sitecore Support Ticket and Sitecore responded quickly and provided me with a Support dll. 

To track the future status of this bug report go to:

Related to WFFM 8.0 rev. 151127

1 comment:

Paul Urban said...

You saved my life my friend. I ran into that issue 2 years later. I inherited old Sitecore project.