How to substitute values in docx template for single value fields

Hi,

I have created a template using Docx  and able to generate table with dynamic data in docx file.

But how do I populate the values for  single fields.

I want to generate the pdf as shown in the mockup

  Discussion posts and replies are publicly visible

Parents
  • it's similar to how you are populating data in the table, could you plz attach xml data that you are passing in for the template

  • templateDocx.docx

    rule!tableRowData() code:

    "<rowvalues name = "&"'"&index(ri!tableData, "name", null)&"'"&" dob= "&"'"&index(ri!tableData, "dob", null)&"'"&" address= "&"'"&index(ri!tableData, "address", null)&"'"&" />"

    This rule has only one variable i.e. "tableData" of cdt type and it is not a multiple type.

    rule!xmlData() code:

    stripwith("<DocFromDynTemp><username>'xxxx'</username>

    "&fn!apply(rule!tableRowData(tableData: _), ri!tableData)&"</DocFromDynTemp>", ";")


    Again I have the same variable i.e. "tableData" of cdt type and it is multiple type.


    After creating these two rules call rule!xmlData() in xmlDataModel input variable of DOCX from Dynamic Template smart servicthee by passing the cdt type variable as input to the rule.


    For testing purposes i passed the below data as input
    {
     {
      name: "ram",
      dob: today(),
      address: "abcd"
     },
     {
      name: "raj",
      dob: today(),
      address: "efgh"
     }
    }

    And i am attaching the base template

  • 0
    A Score Level 2
    in reply to Soujanya B

    Hi Soujanya, 

    When the XML which is passed from Appian should be like below:

    <body>

    <title>ri!documentTitle</title>

    "<rowvalues name = "&"'"&index(ri!tableData, "name", null)&"'"&" dob= "&"'"&index(ri!tableData, "dob", null)&"'"&" address= "&"'"&index(ri!tableData, "address", null)&"'"&" />"

    </body>

    Pass the value of ri!documentTitle and in the document template and where ever you need this document title, please give as below:

    «${ MERGEFIELD $doc.body.title}\* MERGEFORMAT» 

    I hope this helps. 

  • Hi Sreedevi,

    If want t display several sections and each section with multipe  fields , do I need  use merge everywhere ?

    Can you please help me in creating the template and how to create the xml document in populating the fields ?

    As shown below

    Section :1

    Name :                    ID:

    DOB:                      EmailId:

    Address

    Section:2

    dynamic Table data

    Section :3

    Organiation name :

    Place:

    thanks

    Soujanya

Reply
  • Hi Sreedevi,

    If want t display several sections and each section with multipe  fields , do I need  use merge everywhere ?

    Can you please help me in creating the template and how to create the xml document in populating the fields ?

    As shown below

    Section :1

    Name :                    ID:

    DOB:                      EmailId:

    Address

    Section:2

    dynamic Table data

    Section :3

    Organiation name :

    Place:

    thanks

    Soujanya

Children
No Data