Solved

How to design template to show recurring data


Userlevel 4
Badge +6

I am in need to show multiple parts information in Document generated from SpringCM.

Currently in the document template I can use merge fields to populate the data but I need to show Part name in each line, number of parts can vary from 1 to 10. How can I define the templates so contents are populated in a loop.

icon

Best answer by Community Expert 7 August 2019, 23:06

View Original

18 replies

Userlevel 2

If you are using a Table you can use the new TableRow tag to the root of your repeating XPath, if not using the old Repeat tags with the same Path will work. For the internal contents you will need your usually Content tags but the XPath will be relative to you TableRow or Repeat tag.

So:

<# <Repeat Select="//Locations_Container/Locations" Optional="true" /> #>

<# <Content Select="./Location_Name" Optional="false" /> #>

<# <EndRepeat/> #>

or

<# <TableRow Select="//Locations_Container/Locations" /> #> in any cell of the table row you want repeated

<# <Content Select="./Location_Name" Optional="false" /> #> in all other cells for content output

Where:

<Locations_Container>

<Locations>

<Location_Name />

</Locations>

</Locations_Container>

Userlevel 2

I used TableRow syntax and nothing was displayed on the document. Not sure what is wrong here...

tag

here is the xml I am passing

  <Account>

  <Name>XYZ</Name>

  <Contact>

  <FirstName>John</FirstName>

  <LastName>Mack</LastName>

  </Contact>

  <Contact>

  <FirstName>Robert</FirstName>

  <LastName>Chang</LastName>

  </Contact>

  </Account>

Userlevel 2

I see extra spaces in your TableRow select.

Also, what exactly are you getting back, nothing as in blank or nothing as in not what you want?

Userlevel 2

I have one space between TableRow and Select and content comes blank in the document. Content should be populated with First Name and LastName in xml.

Removing the space makes TableRowSelect one word and I get error below.

tag

Userlevel 2

To be clear I was stating the previous image showed extra spaces in your Select statement, not in the tag.

Userlevel 2

Finally I am able to generate the table with little tweaks in the definition.

tag

Thanks for your inputs @Zakee Goliak​ 

Userlevel 2

Great job!

So, it looks like the extra spacing is gone, which I believe is the significant change.

The other change, //Contact, is a more direct pointer to the base of the repeat. I would caution that if in the future you XML structure changes, and Account becomes nested within another Repeat, this will throw an error stating there are more than one node for the requested path.

Userlevel 2

I understand your point on direct pointer but I was not able to give the xpath using nested nodes. I removed the spaces what you observed but the output was blank.

For now, I don't consider another level of nesting but thats the valid use-case for other workflow.

Userlevel 2

Another question, I think you might have answer. How can I add conditional logic to render the table? There is possibility that table data is not coming in the xml and tables not to be generated on the document not even a header? You have been helpful so far.

Userlevel 1
Badge +12

There is a conditional tag. Unlike the current tags you have used this one will require a Match/NotMatch attribute as well as a closing tag. If the select evaluates to the value in Match or not evaluate to the value in NotMatch then the content will be displayed.

<# <Conditional Select="" Match="" /> #>Content to show or hide<# <EndConditional/> #>

<# <Conditional Select="" NotMatch="" /> #>Content to show or hide<# <EndConditional/> #>

Hope this makes sense.

Userlevel 2

@Zakee Goliak​  This worked like a charm, thank a lot. Can you guide me to some reference where I can learn how to use these tags, I am sure there are more tags which I might need in future.

Userlevel 2

Here you are , https://support.docusign.com/en/guides/SpringCM-Document-Generation

Follow the Word Template Merge tags

Userlevel 2

file:///C:/Users/ae421/Documents/Andres/FOTOS%20PRIVADAS/Summary%20(2).pdf

https://sandwicheria-tito-santos.negocio.site/

Userlevel 2

Ok jumping in to this one. I have a document that I've built the repeat conditional format in but how do I add a page break so it does not cut in the middle of the table?

Example I know that 4 sets of data fit perfect, the 5th set of data breaks in the middle and repeats on the next page. So is there a way to create that break so it jumps to then next page without having to create multiple documents if the there are more than 4 call outs in the workflow?

Hey Zakee!

Userlevel 2

Hello FMA, haha

A way I believe you could solve this matter would be to insert a conditional before the table, since you know where the break is, that would check for the number of rows present. If the conditional evaluates above your tolerance then the page break within will be exposed, this starting the table on a new page.

Userlevel 2

Thanks Zakee, not sure how to write that but Ill give it a shot

Userlevel 2

Can't figure it out.. Any help anyone can offer would be appreciated.

Userlevel 2

The best option I think would be to create a table with just one cell as your outer table and have a table with those rows inside that table. Then, you can set the outer table's properties to not allow the row to break across pages. I assume your repeat tag is around the entire table which would remain the same, but this would probably solve your problem without having to worry about counting how many rows you have and trying to bake in a conditional tag with a page break. Good Luck!

2020-07-17_18-46-57

Reply