I am using Sitecore 9 forms and I have created a custom save action and my requirement is I need to get Form feed value in my CustomSaveAction class which inherits SubmitActionBase class.

I am able to see the data in formSubmitContext object but not able to retrieve the data.

Can you please help me?

Thanks in advanced.


1 Answer 1


You can find an example here: https://ggullentops.blogspot.com/2017/10/sitecore-9-forms-custom-submit-action.html

E.g. to get the value from a field called "Email":

var postedFormData = formSubmitContext.PostedFormData;
var field = postedFormData.Fields.FirstOrDefault(f => f.Name.Equals("Email"));
if (field != null)
    var property = field.GetType().GetProperty("Value");
    var postedEmail = property.GetValue(field);
    email= postedEmail.ToStringOrEmpty();

Not sure if this is still the best way to do it, but that used to work.

Seen some more recent code, and apparently what is done now is:

var email = GetValue(formSubmitContext.Fields.FirstOrDefault(f => f.Name.Equals("Email"));

GetValue function:

private string GetValue(object field)
  return field?.GetType().GetProperty("Value")?.GetValue(field, null)?.ToString() ?? string.Empty;
  • I am not getting how you got PostedFormData in SubmitAction? Feb 19, 2019 at 8:42
  • Adapted answer.. snippet from more recent code. PostedFormData might have disappeared - I should check that.
    – Gatogordo
    Feb 19, 2019 at 9:15
  • You can use formSubmitContext.Fields instead of formSubmitContext.PostedFormData.Fields. Feb 19, 2019 at 10:06
  • Hi Jan, thanks for help...i did the same what you suggested and i am getting the result. Feb 20, 2019 at 9:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.