We have created Polls for our application using Sitecore forms. The rendering we have created to load the poll have set of personalization rules. On first load, form is not loading. Instead it throws 404 page. If we are refreshing the page, form is loading properly.

Below is the implementation that we have followed.
1.Designed sitecore form for Poll with radio button and save data submit action
2.Created controller rendering in Sitecore and mention controller and action name respectively
3.Added the controller rendering in the layout
4.Added personalization rules in the rendering to target context datasource
5.Added "Mvc Form" rendering in the layout.

In view, called the Form.cshtml as below

@model TestProject.PollData.PollViewModel
else if (Model != null)
    <div class="col-md-6 col-lg-6 col-xl-4">
        <div class="card mb-4">
            <div class="card-header">
            <div class="card-body pollSurveryForm">
                <h5 class="card-title">How would you rate our experience?</h5>

Form.cshtml will be loaded in the above mentioned placeholder.

    using (Html.BeginRenderRouteForm(Model, IsPost))
        @Html.Hidden(AttributeNames.FormItemId, Model.ItemId)

        <script type="text/javascript">
            (function($) {
                var $formEl = $("form[data-sc-fxb='@Model.ItemId']");
                if ($formEl.length && typeof $formEl.init_fxbConditions === 'function') {
                    var options = @Html.RenderConditions(Model);

But the issue is Form.cshtml is NOT LOADING on first load. We have to refresh/reload the page, then Form.cshtml is loading with correct form.

Personalization rules in Sitecore:

Personalization in Sitecore

  • Are there any errors in log file? Do forms work on first load if you disable personalization?
    – Marek Musielak
    May 31, 2021 at 19:48
  • why is this not just and if statement instead of else if (Model != null) ? Jun 22, 2021 at 13:17


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.