Tell Skuid template NOT to process merge syntax...

  • 1
  • Question
  • Updated 1 month ago
  • Answered
I feel bad even asking this one...

But is it possible to tell Skuid to not process merge syntax in a particular template? We're building a mail-merge tool in Skuid an want to provide the user with a list of merge fields they can use in the template - but of course Skuid just tries to merge the fields in the list!

Annoying question - I know!

Cheers!

Louis


Photo of Louis Skelton

Louis Skelton

  • 4,878 Points 4k badge 2x thumb

Posted 2 months ago

  • 1
Photo of Matt Davis

Matt Davis, Employee

  • 654 Points 500 badge 2x thumb
I may not be fully clear on the use case, but it sounds like something you can do with UI fields and conditional merge syntax. For each optional field you want them to be able to select, you could have a UI only checkbox that the user selects to include or not include the field. Then in your template, you have {{#checkbox}}{{field}}{{/checkbox}}. This says to only show the field if the checkbox is true. Here's a quick example of what I'm thinking:
<skuidpage unsavedchangeswarning="yes" personalizationmode="server" showsidebar="true" useviewportmeta="true" showheader="true">
    <models>
        <model id="Oppty" limit="1" query="true" createrowifnonefound="false" datasource="salesforce" sobject="Opportunity">
            <fields>
                <field id="Name"/>
                <field id="ShowName" uionly="true" displaytype="BOOLEAN" label="ShowName" ogdisplaytype="TEXT" defaultvaluetype="fieldvalue" defaultValue="false"/>
            </fields>
            <conditions/>
            <actions/>
        </model>
    </models>
    <components>
        <basicfieldeditor showheader="true" showsavecancel="true" showerrorsinline="true" model="Oppty" uniqueid="sk-xwG-294" mode="edit">
            <columns>
                <column width="50%" uniqueid="sk-xwG-290">
                    <sections>
                        <section title="Section A" uniqueid="sk-xwG-291" collapsible="no">
                            <fields>
                                <field uniqueid="sk-xwJ-313" id="ShowName"/>
                            </fields>
                        </section>
                    </sections>
                </column>
                <column width="50%" uniqueid="sk-xwG-292">
                    <sections>
                        <section title="Section B" uniqueid="sk-xwG-293">
                            <fields/>
                        </section>
                    </sections>
                </column>
            </columns>
        </basicfieldeditor>
        <richtext multiple="false" uniqueid="sk-xwK-318" model="Oppty">
            <contents>&lt;p&gt;{{#ShowName}}{{Name}}{{/ShowName}}&lt;/p&gt;
</contents>
        </richtext>
    </components>
    <resources>
        <labels/>
        <javascript/>
        <css/>
        <actionsequences uniqueid="sk-xw6-218"/>
    </resources>
    <styles>
        <styleitem type="background" bgtype="none"/>
    </styles>
</skuidpage>

Photo of Louis Skelton

Louis Skelton

  • 4,878 Points 4k badge 2x thumb
Hey Matt, thank you but I think I probably didn't explain myself very clearly. What I'd like to do is have merge syntax written on the page (in a Template component) but not actually processed by skuid (i.e. it just shows the field name in the curly braces). So it'd look like this:
Here is my template content. Here is a {{merge_field}}. The merge field is shown with the curly braces and is not processed by Skuid.
I can then give the user a list of merge fields which they can then use when creating a mailmerge templates for generating pdf letters. E.g:
Please use the following merge fields when creating your document: 

Opportunity Name = {{Name}}
Account Name = {{Account.Name}}
Date = {{CloseDate}}
At the moment when I try to do this it, of course, tries to process the merge syntax so you just end up with:
Opportunity Name = 
Account Name = 
Date =
I think I can probably just use javascript to insert the information which then won't be processed by Skuid's mailmerge api on render, e.g. via:
$("#table-of-merge-fields-for-user").html("<table>MY LIST</table>");
(Edited)
Photo of Matt Davis

Matt Davis, Employee

  • 654 Points 500 badge 2x thumb
Gotcha, my bad on the misunderstanding. I ran into something like this before, and my workaround was a little funny but what I did was insert the brackets via merge syntax. So I created UI only fields "OpenBrackets" (default to {{ ) and "CloseBrackets" (default to }} ). Then in your list have Opportunity Name = {{{OpenBrackets}}}Name{{{CloseBrackets}}}.

When it processes merge syntax, it should process {{{OpenBrackets}}}Name{{{CloseBrackets}}} => {{Name}}
Photo of Louis Skelton

Louis Skelton

  • 4,878 Points 4k badge 2x thumb
Oh wow! That's a super neat idea! Thanks! :D

Always a way!
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
Brilliant!
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
Right. Is there an 'escape' key to ask skuid not to process the merge syntax?

Otherwise, inserting directly into the html with jquery is probably your best bet.