WFFM Custom Field – Form Name Field
I recently had a requirement for capturing the form name on submission so that the client can determine exactly which form a particular lead came from.
I am using a Web Forms for Marketer (WFFM) for Sitecore (version 8.1 rev 160523) which integrates with Microsoft Flow to generate a lead in Dynamics 365 CRM.
The client would like to populate the “Topic” field in their CRM in the following format: – . For example, “Request a Quote – United Kingdom”.
The selected location is already available on form submission but not the form name.
I decided on creating a custom field which would be populated on submission. This field will be rendered as a hidden input.
My first approach was to get the
FormId which is already available to
FormId and the majority of SingleLineTextField properties were
My second approach was to retrieve the rendering of the form on the current page as this will have the data source which directly links to the target form.
GetRenderingByTemplate is an extension method:
This is paired with a Razor view:
Instructions on how this is configured in Sitecore can be found in Sitecore’s documentation here.
The result is a hidden field which includes the form’s name in the submission.