November Happy Hour will be moved to Thursday December 5th.
November Happy Hour will be moved to Thursday December 5th.
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.
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.
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.
And how do I get the formIdentity, it is not exposed as parameters to that method?
Also, I tried subscribing to:
FormsEvents.Instance.FormsSubmitting
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?
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.
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.
Here is how to retrieve form guid and language
var formLanguage = rawSubmittedData[Constants.FormLanguage]; var sFormGuid = rawSubmittedData[Constants.FormGuidKey] as string;
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?