When creating a custom submit action in Sitecore Forms, all you need to do is to inherit the SubmitActionBase base class and override the Execute method, right? Wrong!
In this article, I want to share some gotchas when creating a custom submit action in the Sitecore Experience Forms.
Sitecore Forms, announced in the Sitecore Symposium 2017 and available at the Sitecore Experience Platform 9.0 Initial Release, comes with a completely redesigned UX that enables marketers and content authors to create forms from templates, create new forms by dragging and dropping Form elements such as textboxes, labels, lists, and etc. It promisses to completely replace the WFFM soon.
One of the features present in both WFFM and Experience Forms is the submit action (in WFFM they are called save actions) which are additional actions performed when a form is submitted. Altough, the Sitecore 9 – Update 1 brought a new submit action – Send Email Campaign Mesage – Experience Forms still lacks some very important submit actions that are present in the WFFM.

In the same manner WFFM enabled you to create custom save actions, Experience Forms also enables you to create custom submit actions. If you want to get started with custom submit actions please read the following walkthroughts:
- Walkthrough: Creating a custom submit action
- Walkthrough: Creating a custom submit action that updates contact details
- Sitecore 9 Forms: custom submit action
- Form Submit Actions in Sitecore 9
When creating a custom submit action in the Sitecore Forms, you inherit the Sitecore.ExperienceForms.Processing.Actions.SubmitActionBase class.
Below is the definition of the SubmitActionBase class:
All you need to do (theoretically) is to override the Execute method, right? Wrong!
Recently, I was struggling with the code below. I couldn’t figure out what was wrong with it.
Whenever I clicked the submit button in my website, I would get the error message that you set in the Error Message field of the custom submit action.

Investigating it a bit further, I found the reason why my code wasn’t working. It was because I was using the string type parameter in the SubmitActionBase, but wasn’t overriding the TryParse method.

It doesn’t happen if you use strongly typed parameter in the SubmitActionBase class.
Why does it happen?
If you decompile the Sitecore.ExperienceForms.Processing.Actions.SubmitActionBase class you’ll notice some interesting things.

Where does the “parameters” in the ExecuteAction come from? It comes from the submit action item that was created throught the Experience Forms Editor when you add a submit button.

How to fix it?
Below I list three alternatives to work this around.
1. Use a strongly typed parameter in the SubmitActionBase (recommended)
2. Override the TryParse method (recommended)
3. Add parameters to your submit action
The problem with this approach is that you have to remember to fill the parameter field whenever you create a new form and add the submit action to a submit button.

That’s all for today!
Hmmm, this is weird, even if I am using a strongly typed model class to map the fields, I am still getting empty Guids in my Execute method. Could you explain how the mapping of the fields work on the background?
LikeLike
Hi. In this case, I recommend you post a question on Sitecore Stack Exchange https://sitecore.stackexchange.com/questions along with some code from your implementation.
LikeLike
Any idea why no matter what I do, my code won’t debug? I’ve written the custom action and in the form- model, i’ve set the Namespace ClassName. But no matter what I do, the debug point in the Execute Method will not get hit.
It says No symbols were loaded. I’ve even manually copied the dll over to the website bin folder.
LikeLike
Check if the build configuration is “Debug” and if the .pdb files are being published. Sometimes, publish profiles, if you are using msbuild publish, are set for “Release” mode by default
LikeLike
I found the issue, the project was in debug, but that particular class file was set to “Content” instead of compile. Thank you!
LikeLike
Nice! Glad you have found it!
LikeLike