Skip to main content

Notifications

Announcements

No record found.

Customer experience | Sales, Customer Insights,...
Answered

CRM 2015, Make a poll bilingual inside portal

Posted on by 30

Hello,

I'm trying to add a poll to a web page of a crm portal. I managed to get it to work just fine in one language, but my portal supports 2 languages (English and French). Is there a way to make it bilingual?

Right now the way that I thought about was to add both sentences (ex: Do you like red? / Aimez-vous le rouge?) and then use JS to delete the part that is not needed when I load the page. The problem that I encountered is that when I use

       {% include 'poll' poll_name:"Test Poll 1" %} 

all that my jQuery sees is :

      <div class="poll" data-url="/_services/polls/10152feb-f33d-4cbd-997e-f7a336c3b8bf/65adeb71-a0b4-ea11-811c-005056b067c6" data-submit-url="/_services/polls/10152feb-f33d-4cbd-997e-f7a336c3b8bf/SubmitPoll?id=65adeb71-a0b4-ea11-811c-005056b067c6"></div>

It doesn't seem to see the html code that is added for the poll.

Does anybody know of a way to make it work?

Here is my code :

<div id="myInclude">
        {% include 'poll' poll_name:"Test Poll 1" %}
</div>
<script type="text/javascript">
        var htmlLang = $("html").attr("lang");

        $(document).ready( function() {
            var a = $("#myInclude").html();
          
            console.log(a);  
        });

Thank you
       

  • dev2143 Profile Picture
    dev2143 30 on at
    RE: CRM 2015, Make a poll bilingual inside portal

    This solution worked. I can now access the elements with jQuery.

    Thank you very much!

  • Verified answer
    OmarZaarour Profile Picture
    OmarZaarour 1,705 on at
    RE: CRM 2015, Make a poll bilingual inside portal

    I actually found out why you jquery doesn't find the html. The poll loads async after the document ready. One possible way is to wait for the poll to appear which I tested and worked below. I'm targeting the div that contains the html directly not its parent div. I borrowed the code that checks for element existence online.

    <div id="test">

          {% include 'poll' poll_name:"Yes or No Question" %}

    </div>

    <script type="text/javascript">

           var htmlLang = $("html").attr("lang");

           $(document).ready( function() {

               waitForElementToDisplay("div[data-name*='Yes or No Question']",100);        

           });

    function waitForElementToDisplay(selector, time) {

           if(document.querySelector(selector)!=null) {

               var a = $("div[data-name*='Yes or No Question']").html();

                 console.log(a);  

               return;

           }

           else {

               setTimeout(function() {

                   waitForElementToDisplay(selector, time);

               }, time);

           }

       }

           </script>

  • OmarZaarour Profile Picture
    OmarZaarour 1,705 on at
    RE: CRM 2015, Make a poll bilingual inside portal

    You are right I missed that. OK back to your original issue. When I tested the same logic you had, I'm able to see the html of the poll, can you see the same in your dev tools?

    3073.pastedimage1592947439507v1.png

  • dev2143 Profile Picture
    dev2143 30 on at
    RE: CRM 2015, Make a poll bilingual inside portal

    Yes, I thought about that, but the only problem I have with it is that (correct me if I'm wrong) after voting each poll would only display the results for that specific poll (ex: The French poll only shows the votes for the users using french and The English poll only shows the results of the users using English. Votes can be aggregated later(that's not really a problem), but the users that are voting won't see the exact results, so I don't think that it would be a good solution.

  • Suggested answer
    OmarZaarour Profile Picture
    OmarZaarour 1,705 on at
    RE: CRM 2015, Make a poll bilingual inside portal

    Have you considered creating two polls, one in English and one in French? Then in the Poll Placement, create your own web template to render one of the polls based on the current website language. You can get the current language using this liquid command
    {% assign languagecode = website.selected_language.code %}

    Yes it is a bit more work to sum up the results later for both polls but it is worth it if it makes things cleaner.

    Here is a reference to how you can add a poll using liquid https://community.adxstudio.com/products/adxstudio-portals/documentation/configuration-guide/customization-tools/polls/

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans