26 February 2018

WFFM Web form for marketer fail to submit in Sitecore

I have setup a standard form using WFFM in Sitecore 8.2. It always fail when submit. Error as below,


Exception: System.Data.DataException
Message: Error executing SQL command: SELECT df.Dropouts, df.Failures, df.Submits, df.Success, dv.Visits FROM
(SELECT [dbo].[Fact_FormStatisticsByContact].[FormId] AS FormId, 
SUM([dbo].[Fact_FormStatisticsByContact].[Submits]) AS Submits, SUM([dbo].[Fact_FormStatisticsByContact].[Failures]) AS Failures,
SUM([dbo].[Fact_FormStatisticsByContact].[Dropouts]) AS Dropouts, SUM([dbo].[Fact_FormStatisticsByContact].[Success]) AS Success
FROM [dbo].[Fact_FormStatisticsByContact] WHERE [dbo].[Fact_FormStatisticsByContact].[FormId] = @FormId
group by [dbo].[Fact_FormStatisticsByContact].[FormId]) df INNER JOIN

(SELECT Count(distinct [dbo].[Fact_FormEvents].[InteractionId]) AS Visits,
[dbo].[Fact_FormEvents].[FormId] AS FormId 
  FROM [dbo].[Fact_FormEvents]
  WHERE FormId = @FormId
  GROUP BY [dbo].[Fact_FormEvents].[FormId]  ) dv ON df.FormId = dv.FormId

Nested Exception

Exception: System.Data.SqlClient.SqlException
Message: Invalid object name 'dbo.Fact_FormStatisticsByContact'.
Source: .Net SqlClient Data Provider
   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
   at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
   at System.Data.SqlClient.SqlDataReader.TryConsumeMetaData()
   at System.Data.SqlClient.SqlDataReader.get_MetaData()
   at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString, Boolean isInternal, Boolean forDescribeParameterEncryption)
   at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest)
   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry)
   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
   at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
   at Sitecore.Data.DataProviders.Sql.DataProviderCommand.ExecuteReader()

I just realized this is what I missed:

After run the .sql , the submit works!

14 February 2018

Copy item values to new language version in Sitecore

There is a requirement in multi-lingual sitecore setup, when we create a new non default language version for an item, the content editor keen to have the functionality to copy over all the fields values to save them some time from manually setup all again for each language.

(The code has been tested against Sitecore 8.2 and I cannot see why it does not work for later version.)

First, you need to setup Sitecore multi Lingual properly. reference to link

Then code sample:

using Sitecore.Data.Items;
using Sitecore.Events;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Sitecore.Data.LanguageFallback;
namespace Test.Feature.Language.Pipelines
    public class CopyEnglishContent
        public void OnVersionAdded(object sender, EventArgs args)
            var item = Event.ExtractParameter(args, 0) as Item;
                if (item != null && item.Version.Number == 1)
                    var fallbackItem = item.GetFallbackItem();
                    foreach (Sitecore.Data.Fields.Field field in fallbackItem.Fields)
                        if ((!field.Shared && !field.Name.StartsWith("__") && field.Name.Trim() != "") || field.Name == "__Final Renderings")
                            item.Fields[field.Name].SetValue(field.Value, true);
            catch (Exception ex)
                if (item != null)

Apart from above, we just need to put it in the right spot for configuration purpose.

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
      <event name="item:versionAdded">
        <patch:delete />
      <event name="item:versionAdded">
        <handler type="Test.Feature.Language.Pipelines.CopyEnglishContent, Test.Feature.Language" method="OnVersionAdded" />

That is all.


1. Select "Fallback version" for Portuguese.

2. "Add a new version"

3. A new version have been created for "Portuguese"

Done! Happy Sitecoring!




WFFM Web form for marketer fail to submit in Sitecore

I have setup a standard form using WFFM in Sitecore 8.2. It always fail when submit. Error as below, Error: Exception: System.Data.DataE...