Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
AI OnAI Off
Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
Hi,
Hi,
Thanks for your reply. Regarding the second question, the code satisfies my requirements quite well, but I was trying to make sure it falls within the regular way of doing things with Episerver Forms, which will still be working in future versions.
I would like to present users with feedback on the result of a webservice call in which data from a form is submitted to the webservice. The most straightforward way to do this seems to be to call the service from the controller for the page displayed after submission (the "thank you page"). The result of the webservice call can then be passed directly to the view for this page. When using an actor this is more complicated.
Two questions:
The code I want to use is more or less like this:
public class ThankYouPageController : PageControllerBase { public ActionResult Index(ThankYouPage currentPage) { var formGuid = Request.QueryString["__FormGuid"]; var languageBranch = Request.QueryString["__FormLanguage"]; var formSubmissionId = Request.QueryString["__FormSubmissionId"]; if (!string.IsNullOrEmpty(formGuid)) { var contentRepository = ServiceLocator.Current.GetInstance(); var formDataRepository = ServiceLocator.Current.GetInstance(); var formRepository = ServiceLocator.Current.GetInstance(); var currentForm = contentRepository.Get(new Guid(formGuid)); if (currentForm != null) { var formIdentity = new FormIdentity(new Guid(formGuid), languageBranch); var rawSubmittedData = formDataRepository.GetSubmissionData(formIdentity, new[] {formSubmissionId}).FirstOrDefault(); var friendlyNames = formRepository.GetDataFriendlyNameInfos(formIdentity); if (rawSubmittedData != null) { var submittedData = formDataRepository.TransformSubmissionDataWithFriendlyName( rawSubmittedData.Data, friendlyNames, true).ToList(); var dataToPost = submittedData.Where(x => x.Key == "DataToPost").Select(x => x.Value).FirstOrDefault()?.ToString(); // Call webservice here with dataToPost and present user feedback in the ThankYouPage // currentPage.userFeedback = webservice.Result; } } } var model = CreateModel(currentPage); return View(model); } }
Submit
[Pasting files is not allowed]