General Discussion

  • 1.  Multiselect box formatting in email destination

    Adopter
    Posted 10-03-2024 12:15
    Edited by Chad Anderson 10-03-2024 12:16

    I'm wanting to create a fairly generic customer feedback form but am running into some issues with how the multiselect box outputs its data. Ideally what I am trying to accomplish is a quick form that our customers can enter their contact info, select from a checklist products that interest them (those checklist items contain the server value of a weblink pointing to our website with the selected product info) and then the output would be an email with the links to all of the products they've selected

    The output i'm currently seeing in the email body when selecting all 3 boxes is this:

    The output I am looking for would be no brackets, and instead of checklist separation of a comma to use a line break so each selected link is on its own line:

     

    ----- Checklist test

    https://www.test.com/product1

    https://www.test.com/product2

    https://www.test.com/product3

     

    I've looked at all of the DREL documentation and tried all of the switches I could see from those pages but nothing changed the output style to something that worked here.

     

    I'm also open to other question types as a solution, but the only one i've tested that has had an output similar to what I'm looking for was individual radio buttons for each product and that lead to other issues such as gaps between the output links if for instance I only select 1 and 3 it looks like:

     

    https://www.test.com/product1

     

    https://www.test.com/product3

     

    Which isn't the worst for small selection sizes but we are planning to have quite a few products in the lists



    ------------------------------
    Chad Anderson
    I.T. Technician & Systems Developer
    TACADA
    AB
    ------------------------------



  • 2.  RE: Multiselect box formatting in email destination

    Adopter
    Posted 10-03-2024 14:57

    Hey Chad,

    I can't think of any way to do this with DREL in the e-mail body, but you could do it with Handlebars or Freemarker in a custom text/word/html document that you could attach to the e-mail. 

    I can whip up an example if needed.



    ------------------------------
    Calvin Hunter
    Project Manager
    Vipond Inc
    calvin.hunter@vipond.ca
    ------------------------------



  • 3.  RE: Multiselect box formatting in email destination

    Adopter
    Posted 10-07-2024 12:38

    That would be amazing! I haven't needed anything but DREL so i'm not familiar with those



    ------------------------------
    Chad Anderson
    I.T. Technician & Systems Developer
    TACADA
    AB
    ------------------------------



  • 4.  RE: Multiselect box formatting in email destination

    Adopter
    Posted 10-07-2024 16:12

    No problem - see below. This will just generate a small table of links from your question. "Multiselect" is your question ID. You would just create a custom document (PDF or HTML, below should work in both), select Custom body, and select Handlebars instead of DREL. 

    TC documentation for custom docs is here: https://docs.truecontext.com/1374411/Content/Published/360000345463.html

    Handlebars documentation is here: https://handlebarsjs.com/guide/

    <table>
    <thead>
    <tr>
    <th>URL</th>
    </tr>
    </thead>
    <tbody>
      
    {{#each answers.Multiselect}}
    
    <tr>
    <td><a href="{{this}}">{{this}}</a></td>
    </tr>
    
    {{/each}}
      
    </tbody>
    </table>


    ------------------------------
    Calvin Hunter
    Project Manager
    Vipond Inc
    calvin.hunter@vipond.ca
    ------------------------------



  • 5.  RE: Multiselect box formatting in email destination

    Adopter
    Posted 10-10-2024 16:10

    Your solution is working amazing thanks again for taking the time to help!

    In this section:

    <td><a href="{{this}}">{{this}}</a></td>

    Do you know if that second {{this}} reference it's possible to use the multiselects 'display' text? Then the URL's get even cleaner looking which would be great

    I've been trying to get it working myself for the past few hours but can't seem to figure it out



    ------------------------------
    Chad Anderson
    I.T. Technician & Systems Developer
    TACADA
    AB
    ------------------------------



  • 6.  RE: Multiselect box formatting in email destination

    Adopter
    Posted 10-10-2024 17:23
    Edited by Calvin Hunter 10-10-2024 17:23

    I wasn't able to figure out a way to do that either - I tried for quite a while. The issue is that the options are not stored as array items in the one place where you can get the display text, so there's no (easy) way to reference individual entries. I'm not sure if this is a bug with the data record format or intended but it sure is annoying. It seems like they should be individual array elements but instead it is one array element with multiple objects in it, and handlebars doesn't have a way (that I can find) to access anything but the first object.

    If that's something you need/want, I think I can do it with Freemarker instead of Handlebars. FTL is a bit more complicated which might be annoying (or beneficial?) if you wanted to expand on the document later, but if you just need it for this list of URLs it's pretty simple. I'm out for the day but I'll get you a FTL version tomorrow.



    ------------------------------
    Calvin Hunter
    Project Manager
    Vipond Inc
    calvin.hunter@vipond.ca
    ------------------------------



  • 7.  RE: Multiselect box formatting in email destination

    Adopter
    Posted 10-17-2024 09:11
    Edited by Calvin Hunter 10-17-2024 09:13

    Hey Chad, just wanted to follow up on this, sorry about the delay! I did figure out a way to make it work in Handlebars as well! It wasn't that the array wasn't readable, it was just that Handlebars is awkward and doesn't allow expressions within expressions, so @index wasn't working. Seems they added a new helper to work around that problem at some point - lookup.

    Here is both methods:

    // Freemarker:
    
    <table>
    <thead>
    <tr>
    <th>URL</th>
    </tr>
    </thead>
    <tbody>
    
    <#list dataRecord.pages.Test.sections.Test.answers.Multiselect.values as url>
      
    <tr>
    <td><a href="${url}">${dataRecord.pages.Test.sections.Test.answers.Multiselect.valuesMetadata[url?index].display}</a></td>
    </tr>
     </#list>
    </tbody>
    </table>
    
    // Handlebars:
    
    <table>
    <thead>
    <tr>
    <th>URL</th>
    </tr>
    </thead>
    <tbody>
      
    {{#each answers.Multiselect}}
    
    <tr>
    <td><a href="{{this}}">{{#with (lookup dataRecord.pages.Test.sections.Test.answers.Multiselect.valuesMetadata @index)~}}{{display}}{{/with}}</a></td>
    </tr>
    
    {{/each}}
      
    </tbody>
    </table>



    ------------------------------
    Calvin Hunter
    Project Manager
    Vipond Inc
    calvin.hunter@vipond.ca
    ------------------------------



  • 8.  RE: Multiselect box formatting in email destination

    Adopter
    Posted 10-17-2024 16:36

    This is exactly what I was looking for! This works perfectly

    Thanks again for taking the time to send this



    ------------------------------
    Chad Anderson
    I.T. Technician & Systems Developer
    TACADA
    AB
    ------------------------------



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