How to map Episerver custom form field with MAI

10/27/2019

Episerver

Episerver forms add-on together with inbuild field types represent very good foundation to interact with visitors. You will find a need for custom form field after some time or little bit advanced use case. There has been many useful articles how to make a custom form field. Here are a few of them:

https://blog.mathiaskunto.com/2017/04/12/episerver-forms-notes-on-creating-custom-form-fields/

https://world.episerver.com/documentation/developer-guides/forms/creating-form-element-with-validator/

https://www.david-tec.com/2016/01/building-out-a-custom-form-element-with-the-new-episerver-forms/

I have found having  consent form field like very useful in many cases.  As you (probably) know produce checkbox with text on the right is very straightforward operation by using "Multiply or single choice" form field. However, this field type does not allow full (HTML) text thus having an url in the text beside a checkbox  is mission impossible.

Consent field in its core contains of checkbox and rich-text  field.

My point here is to focus on make custom form field ready for data mapping while utilizing Episerver Marketing Automation package.

Prerequisites, of course, are to install Salesforce add-on n as described on link http://webhelp.episerver.com/latest/addons/marketing-automation/salesforce.htm

Form field data

Form field Model

Notice that model class implements IUIExternalFieldMapping available in EPiServer.Forms.EditView. This will add additional tab to map form field value with marketing automation platform.

Form Field View

Note: Views, by default, are located in ~/Views/Shared/ElementBlocks. This can be changed in forms config file or via source code.  More information about configuration is available on https://world.episerver.com/documentation/developer-guides/forms/configuring-episerver-forms/

 

Source code

The whole solution is available on github.

Conclusion

Episerver forms are very easy to extend and accommodate your project needs whether you stay in CMS itself or want to share form submission values with other applications.