Issue in Docx from Dynamic template

Certified Associate Developer

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

Parents
  • 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

  • +1
    Certified Associate Developer
    in reply to Siddharth

    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.

Reply
  • +1
    Certified Associate Developer
    in reply to Siddharth

    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.

Children