Hello,
I am using DocxFromDynamitecTemplate smart service for generating the dynamic table in Docx file from given template.
but i am getting the only column names, data is not populating in the table.
Here is the xml data that i am passing in a script task.
concat( "<info><row><name>", toHtml("John Samuael"), "</name><branch>", tohtml("CSE"), "</branch><rollNo>", toHtml("abc"), "</rollNo> </row><row><name>", toHtml("Michelle Dsouza"), "</name><branch>", tohtml("IT"), "</branch><rollNo>", toHtml("fgh"), "</rollNo> </row></info>" )
Template file:Test_Template_new.docx
generated file:
Generated dynamic document11122019 (2).docx
Process model:
Please suggest some solution,for dynamic row generation in table in document or suggest any alternate for this.
Discussion posts and replies are publicly visible
Hello anupriyak0002 - Pass the below code as an expression rule to the 'Xml Data Model' field in the smart service. I have attached the template and the generated document as well. Please let me know if this works.
a!localVariables( local!data: { { name: "John Samuael", branch: "CSE", rollNum: "abc" }, { name: "Michelle Dsouza", branch: "IT", rollNum: "fgh" } }, concat( "<info>", a!forEach( items: local!data, expression: "<rowvalues name = " & "'" & fv!item.name & "'" & " branch= " & "'" & fv!item.branch & "'" & " rollNum= " & "'" & fv!item.rollNum & "'" & " />" ), "</info>" ) )
Template : 0451.Template.docx
Generated File : 6708.Generated File.docx
Hi Siddhartha,
Thanks for your help,it is working for this sample data.
But when i tried it for my actual data(cannot shared as it is confidential), i m recieving this below error:
freemarker.core.NonStringException: For "${...}" content: Expected a string or something automatically convertible to string (number, date or boolean), but this evaluated to a sequence+hash (wrapper: f.e.dom.NodeListModel):==> d.@name [in template "fr.opensagres.xdocreport.document.docx.DocxReport@1b62c890!word/document.xml" at line 4, column 1680]The failing instruction:==> ${d.@name} auto-escaped [in template "fr.opensagres.xdocreport.document.docx.DocxReport@1b62c890!word/document.xml" at line 4, column 1678]
Please suggest.
please tell me if you are doing some specific formating in template also.
Do any of your data points contain an apostrophe or doublequote? In addition to using toHtml() you should also replace apostrophe's with ' and double quotes with "
If I replace the apostrophe's(') with ' then i get the error:
Open quote is expected for attribute "name" associated with an element type "rowvalues".
and if I continue with the apostrope(') ,then i am getting the error:
Parsing error in template "fr.opensagres.xdocreport.document.docx.DocxReport@7d2a84be!word/document.xml" in line 4, column 998:Encountered "<", but was expecting: <ID>
Hi,
instead of this
"<info>" Some text "</info>"
use the below one
<info '" & toHtml(Some text) & "'/>