Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Document HTML Template support Mustache?

mikewwaitca
Tera Contributor

Hi everyone,

 

I created an HTML Template in 'sn_doc_template' table, and tried to use Mustache syntax in the 'html_script_body' field. Then created a UI Action to execute the GenerateDocumentAPI() api to generate a PDF file using the html template, once user clicked the form button.

 

Example of mustache syntax in html_script_body:

{{current.number}}

{{#current.variables.new_emp_name}}

<p>Employee Name: {{current.variables.pay_benefit_emp_name}}</p>

{{/current.variables.new_emp_name}}

 

I expected SN would check if 'new_emp_name' variable has value, and show the employee name if yes, otherwise not render the <p>Employee Name..</p> line

 

However, above script was shown as plain text in the generated PDF, result is as below.

{{current.number}}

{{#current.variables.new_emp_name}}

Employee Name: {{current.variables.pay_benefit_emp_name}}

{{/current.variables.new_emp_name}}

 

This means the mustache didn't execute. Therefore, I was wondering if mustache works in html template, or there is any mistake in my script?

Thanks in advance.

0 REPLIES 0