Prevent submission if unable to log


For some of our forms we have a special LogBlock. When a LogBlock exists I want to log something to the db. If that logging is sucessfull the form submission can continue.

However, if logging fails, I want to abort form submission with an error. Any ideas on how to achieve this?

Mar 05, 2018 10:23

You can override PerformDataSubmit method in DataSubmissionService then do your bussiness there. If everything is ok, call the base to do rest of submission process.

Mar 05, 2018 10:40

That sounds like a very valid strategy.  Newbish question but how do I convert the rawSubmittedData to something like SubmissionFriendlyNameInfos available in an Actor. Need to know what types was sent.

Also, how should I structure a "faulty" reponse with SubmitActionResult ?

return new SubmitActionResult()
                IsSuccess = false,
                Message = "Something went wrong",

Also, I need to abort any Actors. Doesn't seem to do that.

What about using the "Instance_FormsSubmitting", could that somehow about the submission.

Edited, Mar 05, 2018 12:59

You can get friendly name mapping for a form like below:

var friendlyNames = _formRepository.Service.GetDataFriendlyNameInfos(formIden);

Use BuildReturnResultForSubmitAction to return error response, it might help.

When something went wrong with your submission you should NOT call base.PerformDataSubmit, this will prevent actors executed.

Mar 06, 2018 3:26

And how do I get the formIdentity, it is not exposed as parameters to that method?

Also, I tried subscribing to:


and then

if something went wrong

private void Instance_FormsSubmitting(object sender, FormsEventArgs e) {
var myLogService= ServiceLocator.Current.GetInstance<MyLogService>();
var formsSubmittingEventArgs = e as FormsSubmittingEventArgs;
// The event fires before the data is submitted so there is an opportunity to interact here

if(!myLogService.logSomething()) {
// We failed to log for some reason, abort!
formsSubmittingEventArgs.CancelAction = true;


Which solution is best in terms of sustainability to changes in future versions? I feeld like DataSubmissionService  is something you CAN create your own but maybe shouldn't?

Mar 06, 2018 7:46
var formIdentity = new FormIdentity { Guid = formGuid, Language = formLanguage };

The formGuid is GUID of the FormContainerBlock.

Handling and cancel submitting event is more official way to archive. If it satisfy your requirement, just use it. otherwise try the override services.

Mar 06, 2018 8:37

I will go with the more official way but for completeness, how do I retrieve the formGuid and formlanguage by only having

public override SubmitActionResult PerformDataSubmit(NameValueCollection rawSubmittedData, HttpContextBase httpContext,
            ControllerBase controller)

Thanks for your help.

Mar 06, 2018 8:46

Here is how to retrieve form guid and language

var formLanguage = rawSubmittedData[Constants.FormLanguage];
var sFormGuid = rawSubmittedData[Constants.FormGuidKey] as string;
Mar 06, 2018 8:56
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.