Sitecore Experience forms- issues and tips

Sitecore was added new form builder in SC9 for marketers to create forms and extract data filled by the website visitors.The easy to use form builder has a drag and drop capability to create the required form in record time.The forms has analytics linked to it so the marketers can quantify how the their forms are performing over the period.

The purpose of the article is to document some of the gotchas and tips.

A. Missing form in the dashboard.

Once you created form in the form builder and save when you look for the forms just created it will be missing in the dashboard.If you look at the content tree the form definitions can still found in the content tree.

Forms3

Reason

Sitecore index the forms content  and store it in the master index .The form dashboard search the index and displays the forms you have created.Since the index was not updated it won’t be displaying in the dashboard.

Troubleshooting steps.

1) Rebuild the master index from the indexing manager

2)Rebuild just the forms content in the content tree using “Re-Index Tree” option in the developer tab.This will be much faster compared to the first option

Forms4

I was also created a custom admin page an use the below code programmatically index the forms content.So the “authors” doesn’t need to have the permission to access “Developer” tab to rebuild the index. The SC9 installation by default using the synchronous index strategy for master index and is very CPU intensive hence it was viable to use that with my installation.

public HttpResponseMessage IndexSitecoreForms( )
{
           var database = Database.GetDatabase("master");
           var dataFolder = database.GetItem("/sitecore/Forms");
           var indexableFolder = new SitecoreIndexableItem(dataFolder);
           var jobs = IndexCustodian.RefreshTree(indexableFolder);
           return new HttpResponseMessage(HttpStatusCode.OK)
          {
            Content = new StringContent("Indexing job created")
          };
}

3)in my case, I was still not able to see the newly created forms, I was using a custom index configuration for the master index in azure search and after including below fields in the index configuration I were able resolve the issue.

<include hint="list:AddIncludedField">
<!--Forms fields-->
<fieldId>{558F9307-EBAF-480D-88B5-DFE9E63A66DE}</fieldId>
<fieldId>{39C4902E-9960-4469-AEEF-E878E9C8218F}</fieldId>
</include>

B. When submit forms page were redirecting to the form builder

You can follow the steps mentioned https://doc.sitecore.com/developers/90/sitecore-experience-management/en/add-a-form-to-a-webpage.html  link to add a sitecore form to a web page. Once you add the form to a page when click the submit button the forms were redirecting to the form builder page in the website.I was adding the form to an existing website. Please make sure you are including these in your layout at the exact location in your MVC page layout.

  • add @RenderFormStyles() and @RenderFormScripts() before the closing </body> tag. This will add the necessary references to the form style sheets and JavaScript files.

C. Export the form data in CSV format

By default when exporting the form data, the file has an extension of .csv however the delimiter internally used by the file is a “semicolon” .So the result won’t automatically open in tool like Excel which is bit annoying for the end users.Please follow the below article to to override this to use the comma

http://www.xcentium.com/blog/2019/04/20/sitecore-forms—export-to-semicolon-file

D. Adding default value for “Label Css Class & Css Class” for the form elements.

Sometime you have to style the forms for follow the existing style guide of your website.Sitecore forms has provide 2 fields for all the form element to input the css styles to be used for the “label” and for the control.

Forms6

Sometime it will be bit “overwork” for marketers to input these values every time they create a new form also has to refer their documentation to fill in the exact name of the css class.

There are couple of option to resolve this

Option-1 Save the form as  “template” and the re-use the form

Forms7

option-2 All the template definitions of the sitecore form elements are stored in the below location in the content tree. Add the default values for the css class in the “standard” values of the individual form elements.When you create the new form this value will be pre-filled in the new form.

Forms5

Forms8

Forms9

 

Leave a comment