AnsweredAssumed Answered

How to pass values from javascript to custom template file in data dictionary?

Question asked by vikash.patel@contcentric.com on Jan 3, 2017
Latest reply on Jan 4, 2017 by vikash.patel@contcentric.com

Hi,

I have created a webscript and this is the code of js file.

var fileNode=companyhome.childByNamePath("Data Dictionary/Node Templates/test.html.ftl");
var doc1=companyhome.createFile("testtemplate123.doc");
var props = new Array(1);
props["docname"] = "tesstttt";
var content=doc1.processTemplate(fileNode,props);
doc1.properties.content.content= content;
doc1.mimetype = "application/msword";
doc1.save();

And a custom template file in Data Dictionary/Node Templates/test.html.ftl.

<html>
<head>
<style type="text/css"><!--
body
{
font-family: Arial, sans-serif;
font-size: 14px;
color: #4c4c4c;
}
a, a:visited
{
color: #0072cf;
}
-->
</style>
</head>
<body bgcolor="#dddddd">
<table width="100%" cellpadding="20" cellspacing="0" border="0" bgcolor="#dddddd">
<tr>
<td width="100%" align="center">
<table width="70%" cellpadding="0" cellspacing="0" bgcolor="white" style="background-color: white; border: 1px solid #aaaaaa;">
<tr>
<td width="100%">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td style="padding: 10px 30px 0px;">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td>
<div style="font-size: 14px; margin: 12px 0px 24px 0px; padding-top: 10px; border-top: 1px solid #aaaaaa;">
<p>Hi,Hello</p>
</div>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<div style="border-top: 1px solid #aaaaaa;"> </div>
</td>
</tr>
<tr>
<td style="padding: 0px 30px; font-size: 13px;">
To find out more about Alfresco visit <a href="http://www.alfresco.com">http://www.alfresco.com</a>
</td>
</tr>
<tr>
<td>
<div style="border-bottom: 1px solid #aaaaaa;"> </div>
</td>
</tr>
<tr>
<td style="padding: 10px 30px;">
</td>
</tr>

</td>
</tr>
</table>
</body>
</html>

 

This code is working fine and i am able to create a file as shown in attached screen shot.

 

How can I pass my variables from javascript to Templates(ftl) file?
and how to access these variables in template(ftl) file?

Outcomes