Take the community feedback survey now.
Take the community feedback survey now.
Hi Espen,
I don't got your idea. But if you want to customize content on a page after visitor submitted the form, please take a look at this article.
Use the "Thank You Page" as your presentation page of company, you can have information about the Form and the has-just-submiitted FormSubmission via url parameters. Base on that parameter, you fetch the FormSubmission, and display the page as you want.
Hi Espen,
I made something similar. The recipients e-mail address is located in a "location page" in Episerver and the same page holds info on what zip-codes it is responsible for.
I created 2 custom form elements; ZipCodeElementBlock and CrmEmailElementBlock, and hook into FormsEvents.Instance.FormsSubmitting += FormsSubmitting;
private void UpdateSubmissionEmailReciver(FormsEventArgs submitArgs)
{
try
{
var formsSubmittingEventArgs = submitArgs as FormsSubmittingEventArgs;
if (formsSubmittingEventArgs == null)
return;
var formElements = submitArgs.FormsContent.Property["ElementsArea"].Value as ContentArea;
var hiddenEmailFields = formElements.GetItems<CrmEmailElementBlock>();
var zipCodeFields = formElements.GetItems<ZipCodeElementBlock>();
if (zipCodeFields == null || hiddenEmailFields == null || !hiddenEmailFields.Any())
return;
var emailField = formsSubmittingEventArgs.SubmissionData.Data.First(i => i.Key.EndsWith("_" + hiddenEmailFields.First().Content.ContentLink.ID.ToString()));
var zipCode = formsSubmittingEventArgs.SubmissionData.Data.First(i => i.Key.EndsWith("_" + zipCodeFields.First().Content.ContentLink.ID.ToString()));
var officePage = ServiceLocator.Current.GetInstance<ISearchService>().FindRegionRegionOffice(zipCode.Value.ToString());
if (officePage != null && !string.IsNullOrEmpty(officePage.CrmEmailAddress))
{
Logger.Log(Level.Debug, $"Redirecting e-mail from {emailField.Value} to {officePage.CrmEmailAddress}");
formsSubmittingEventArgs.SubmissionData.Data[emailField.Key] = officePage.CrmEmailAddress;
}
}
catch (Exception e)
{
Logger.Log(Level.Error, "Failed to map incoming contect request to a regional page", e);
}
}
The result is that the CrmBlock-field in forms will be updated with the e-mail address found on the location page. If nok found the CrmEmailElementBLock has a default value for e-mails. That field can be used in Forms (replacement).
Hi guys,
I'm working on a case where I want to use the same basic form but change recipient based on a factor on the page for the submitted from.
Example:
Contact form on a companys presentation page.
We are presenting a bunch of companies. There's one presentation page in the CMS and based on a parameter (companyId i.e.) we display data for the company specified through the parameter. So there's not individual pages for each company. However, I want the recipient email address to be the company contact email.
I tried hooking on to Submitting-events (http://world.episerver.com/add-ons/episerver-forms/handling-events-for-episerver-forms/) but can't find a way to change recipient.
Is it even possible? Any suggestions on how to accomplish this or any alternative solutions to solve this will be appreciated.