Sitecore Forms: How to identify Contact?

Sitecore Forms represents new feature introduced in Sitecore 9 and newer versions. It is considered as replacement of WffM, but current situation is still little bit painfull. Some features from WffM are missing, and many behavior aspects are not configurable as they are hardcoded in code provided by Sitecore.

In this article we will cover one of missing features – “Identify Contact” submit action, which allows us simply “Identify” anonymous contacts by filling subscription form.

This article reuses and simplifies scenario used in Sitecore Documentation here.

What is “Submit action”

Sitecore Forms allows us to create “Custom submit actions”. They represents pieces of code executed when user clicks on “Submit” button. There is possible to have multiple save actions attached to submit button. In real word , collection of submit actions can look like this:

How to develop “Submit action”

Custom action is represented by class inheriting
SubmitActionBase<T> base class, where T represents data passed as parameter  of submit action.  In our example, we are not using any additional data, so,  simple string will be fine.

Minimal “Submit action” class will looks like:

How to register “Submit action”

When we have developed our submit action, we need to deploy it on our Sitecore instance, and register it.

This happens on node /sitecore/system/Settings/Forms/Submit Actions. Insert new submit action node by right-click and selecting “New Submit Action”.

When new entry is created, fill required configuration data:

Model type – Fully qualified class name of submit action implementation

Error message – Error message to be shown if submit action returns false as return value

Editor – for our action, let’s  leave it empty. But it can contain reference to editor (SPEAK application) which can be used by users when editing forms to configure behavior of submit action.

Identifying contact implementation

Whole body of our submit action, including identifying contact, will be following:

How to customize

This implementation expects that form contains at least following fields: FirstName, SecondName, Email and JobTitle. Respective values of these fields will be used to enrich contact data in contact database.

When identifying contact, sitedemo (defined on line 41 in code) is used as identification source, and email is used as contact identification.

4 thoughts on “Sitecore Forms: How to identify Contact?”

  1. Thanks for the useful article; need to clarify whether “sitedemo” was the name of a contact list ? … or mailer root ?

    TIA

    1. Hello …

      “sitedemo” .. you meant that “sitedemo” on line 41?

      It is just string which is used as “prefix” for identification value. It can be considered like “namespace” in C#.

      Every contact can have multiple identifications(so, it can have one identification from your web application, one from CRM, one from … SAP) and this “identification” source separates these IDs.

      So, one contect can have following identifications:
      source:CRM – value: 776867866
      source:Email – value: tomas.knaifl@actum.cz

      and you can use any of these identification pairs
      to find and load contact – in dependency on with value you have available at that moment.

      Tomas

Leave a Reply

Your email address will not be published. Required fields are marked *