November Happy Hour will be moved to Thursday December 5th.
AI OnAI Off
November Happy Hour will be moved to Thursday December 5th.
Hi,
If I understand right you are collecting form data and then at a later point want to send this data to another service, then yes you can.
Have a look at the iformrepository and iformdatarepository interfaces.
Paul
Yes u should be able to post the controller at a later time, you can use the network tab to look at the post and then post a form to the same location later. You can also use the DataSubmissionService
using EPiServer.Core;
using EPiServer.Forms;
using EPiServer.Forms.Core.Internal;
using EPiServer.Forms.Core.Models.Internal;
using Microsoft.AspNetCore.Http;
using System;
using System.Collections.Specialized;
using System.Linq;
namespace MyNamespace;
public class MyFormsSubmissionService
{
private readonly DataSubmissionService _dataSubmissionService;
private readonly IHttpContextAccessor _contextAccessor;
private readonly IContentLanguageAccessor _contentLanguageAccessor;
public MyFormsSubmissionService(DataSubmissionService dataSubmissionService,
IHttpContextAccessor contextAccessor,
IContentLanguageAccessor contentLanguageAccessor)
{
_dataSubmissionService = dataSubmissionService;
_contextAccessor = contextAccessor;
_contentLanguageAccessor = contentLanguageAccessor;
}
public SubmitActionResult Submit(Guid formId, NameValueCollection rawSubmittedData)
{
if (formId == Guid.Empty)
{
return new SubmitActionResult
{
IsSuccess = false,
RedirectUrl = _contextAccessor.HttpContext?.Request.GetTypedHeaders().Referer.AbsoluteUri ?? "",
Message = "Form id is empty"
};
}
if (!rawSubmittedData.AllKeys.Contains(Constants.FormGuidKey))
{
rawSubmittedData.Add(Constants.FormGuidKey, formId.ToString());
}
if (!rawSubmittedData.AllKeys.Contains(Constants.FormLanguage))
{
rawSubmittedData.Add(Constants.FormLanguage, _contentLanguageAccessor.Language.Name);
}
return _dataSubmissionService.PerformDataSubmit(rawSubmittedData, _contextAccessor.HttpContext);
}
}
We are capturing form submissions and need to submit them on behalf of the user at a later time. Can it be submitted in code?