General Discussion

  • 1.  Showing MultiSelect box values using Handlebars

    Posted 07-19-2024 09:06

    Hello,

    Does some one have some experience on how to show all selected values from a MultiSelect box using HandleBars?

    In my case I have selected 3 values in my MultiSelect but only the first value is showing on my HandleBars output document.

    How can a show all values that have been selected?

    Thank you,

    Peter



    ------------------------------
    Peter Dienaar
    PF developer
    Johnson Controls
    ------------------------------


  • 2.  RE: Showing MultiSelect box values using Handlebars

    Staff
    Posted 07-19-2024 12:00

    Hi Peter,

    Multi-select answer values are stored in an array, so they need to be referenced a little bit differently than other control types. 

    A great way to see the multi-select array format is to use the Reference data pane on the right side of the custom document editor. This is an example of a single multiselect question (with the question label "MultiSelect"), which contains 4 possible answers (A, B, C, D):

    One approach you might use an IF statement for each possible value in the multi-select to conditionally check whether to render a checkmark or unchecked box. 

    An example piece of code which is illustrating this approach:

    {{#pf:if dataRecord.pages.Page1.sections.Section1.answers.MultiSelect.selectOptions.[0].selected "is" "true"}} <img src="https://cdn.icon-icons.com/icons2/2249/PNG/512/checkbox_marked_outline_icon_139811.png" width="10;" height="10;">{{/pf:if}}{{#pf:if dataRecord.pages.Page1.sections.Section1.answers.MultiSelect.selectOptions.[0].selected "is" "false"}}<img src="https://cdn.icon-icons.com/icons2/3249/PNG/512/checkbox_unchecked_filled_icon_200788.png" width="10;" height="10;">{{/pf:if}} <b>A</b> <br/>
    {{#pf:if dataRecord.pages.Page1.sections.Section1.answers.MultiSelect.selectOptions.[1].selected "is" "true"}} <img src="https://cdn.icon-icons.com/icons2/2249/PNG/512/checkbox_marked_outline_icon_139811.png" width="10;" height="10;">{{/pf:if}}{{#pf:if dataRecord.pages.Page1.sections.Section1.answers.MultiSelect.selectOptions.[1].selected "is" "false"}}<img src="https://cdn.icon-icons.com/icons2/3249/PNG/512/checkbox_unchecked_filled_icon_200788.png" width="10;" height="10;">{{/pf:if}} <b>B</b> <br/>
    {{#pf:if dataRecord.pages.Page1.sections.Section1.answers.MultiSelect.selectOptions.[2].selected "is" "true"}} <img src="https://cdn.icon-icons.com/icons2/2249/PNG/512/checkbox_marked_outline_icon_139811.png" width="10;" height="10;">{{/pf:if}}{{#pf:if dataRecord.pages.Page1.sections.Section1.answers.MultiSelect.selectOptions.[2].selected "is" "false"}}<img src="https://cdn.icon-icons.com/icons2/3249/PNG/512/checkbox_unchecked_filled_icon_200788.png" width="10;" height="10;">{{/pf:if}} <b>C</b> <br/>
    {{#pf:if dataRecord.pages.Page1.sections.Section1.answers.MultiSelect.selectOptions.[3].selected "is" "true"}} <img src="https://cdn.icon-icons.com/icons2/2249/PNG/512/checkbox_marked_outline_icon_139811.png" width="10;" height="10;">{{/pf:if}}{{#pf:if dataRecord.pages.Page1.sections.Section1.answers.MultiSelect.selectOptions.[3].selected "is" "false"}}<img src="https://cdn.icon-icons.com/icons2/3249/PNG/512/checkbox_unchecked_filled_icon_200788.png" width="10;" height="10;">{{/pf:if}} <b>D</b>
    This results in the following output when A and C were selected in the form:
    I hope this helps! 


    ------------------------------
    Scott Daly
    Senior Manager, Implementation Services
    TrueContext
    ------------------------------



  • 3.  RE: Showing MultiSelect box values using Handlebars

    Posted 07-24-2024 03:23

    Hello Scott,

     

    Thank you very much.

    I think this will help me. I will try it out.

     

    Regards,

     

    Peter

     






  • 4.  RE: Showing MultiSelect box values using Handlebars

    Posted 07-26-2024 05:20

    Hello,

    I tried it out but I still have an issue.

    I looks like still only my first selected value is being displayed on my output document. 

    For an example in Handlebars see attachment

    In attachment you can find also an example of the result.

    What am I doing wrong here?

    Thanks,

    Peter



    ------------------------------
    Peter Dienaar
    PF developer
    Johnson Controls
    ------------------------------



  • 5.  RE: Showing MultiSelect box values using Handlebars

    Staff
    Posted 07-26-2024 09:49
    Edited by Scott Daly 07-26-2024 09:51
      |   view attached

    Hi Peter,

    I believe I see why this isn't working in your example and it's due to the fact you're not using the full path to the question (you're accessing the question through the flattened answers structure at the top of the reference data). I've attached a video walking through this in a little more detail.

    I suspect you could get this working using just the flattened "answers." structure, but you would need to adjust your IF logic to not depend on the selected=true/false. 

    Hope this helps! 



    ------------------------------
    Scott Daly
    Senior Manager, Implementation Services
    TrueContext
    ------------------------------



Reminder: Content posted to our Community is public content.  Please be careful not to post Intellectual Property that you do not have permission to share.  For more information please refer to our Terms Of Use