November Happy Hour will be moved to Thursday December 5th.

programetically getting Episerver Forms Submitted data

Vote:
 

Dear all,

   I want to display submitted form data in page programetically  . i want code for form submitted data 

Thanks®ard

Uday

#178282
May 07, 2017 9:56
Vote:
 

Hi Uday,

You can use IFormDataRepository (inside EPiServer.Forms.Core.Data namespace) to get submitted data:

List<Submission> submittedData = _formDataRepository.GetSubmissionData(
    new FormIdentity(formGuid, languageBranch),
    DateTime.Now.AddDays(-100),
    DateTime.Now).ToList();
#178284
May 07, 2017 14:23
Vote:
 

Hi Dejan Caric,

Thanks for your replying, I tried your sample code but in formidentity i didn't get language from form identity. Could you please see below code for my code 

private Injected<IFormRepository> _formRepository;

public ActionResult Index(FormPageType currentPage)
{
FormDataRepository _formDataRepository = new FormDataRepository();
var formsInfo = _formRepository.Service.GetFormsInfo(null);

/* Implementation of action. You can create your own view model class that you pass to the view or
* you can pass the page type for simpler templates */
foreach (var info in formsInfo)
{
List<Submission> submittedData = _formDataRepository.GetSubmissionData(
new FormIdentity(info.FormGuid, info.language),
DateTime.Now.AddDays(-100),
DateTime.Now).ToList();
}
return View(currentPage);
}

I tried above code but i got info.language is not getting from form identity class. Could you please help me how to solve this?

Thanks, 

Uday

#178544
May 13, 2017 12:36
Vote:
 

Hi Uday,

I guess you want to get a form data in the language of the current page, so you can try with currentPage.LanguageBranch.

Btw, formRepository.GetFormsInfo doesn't return all forms. It's better to iterate trough filtered ContentArea items and look for FormContainerBlocks.

#178551
Edited, May 14, 2017 21:22
Vote:
 

Hi Dejan,

Thanks for your reply it's working well, But i have one more question i'e i have four records in my submitted data, i want to fetch that submited data. How can i do  this could you plese help me?

I tried something like this plese find below;

Index View Code

@if (ViewBag.Getdata.Count > 0)
{
<table>
<tr>
<th>Name</th>
<th>Address</th>
</tr>

@for (int i = 0; i <= ViewBag.Getdata.Count; i++)
{

foreach (EPiServer.Forms.Core.Models.Submission pair in ViewBag.Getdata)
{
{
<tr>
<td>pair.Key</td>
<td>pair.Value</td>;
</tr>
}
}
}
</table>
}

Controller Code

List<Submission> submittedData;


private Injected<IFormRepository> _formRepository;


public ActionResult Index(GetPage currentPage)
{

FormDataRepository _formDataRepository = new FormDataRepository();


var formsInfo = _formRepository.Service.GetFormsInfo(null);


foreach (var info in formsInfo)
{
submittedData = _formDataRepository.GetSubmissionData(
new FormIdentity(info.FormGuid, currentPage.LanguageBranch),
DateTime.Now.AddDays(-100),
DateTime.Now).ToList();
ViewBag.Getdata = submittedData;

Thanks & Regards,

Uday.

#179024
May 30, 2017 7:18
Vote:
 

I want to mapp custom Page Type Input Fields with Microsoft Dynamics CRM fields to pass data from Episerver to CRM as is happing in case of Episerver Forms.

How can i do this please help.

Thanks!

#250994
Mar 19, 2021 10:53
Vote:
 

Aqib - There are connectors available to use with marketing Automation add-on to send data directly to CRM

See Episerver market place https://marketplace.episerver.com/apps/episerver/connect-for-microsoft-dynamics-crm/ 

#251052
Mar 21, 2021 22:02
* 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.