question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Feature Request]: Ability to Inject Word XML into our Templates

See original GitHub issue

Problem to solve It would be nice to be able to inject and render valid Word XML tags into our document templates. Using the following XML as an example:

<w:r>
  <w:rPr>
    <w:b />
  </w:rPr>
  <w:t>This text is bold</w:t>
</w:r>

Injecting this XML into a template field would make the text bold (This text is bold).

Proposed solution Provide a function, e.g., {d.xml_string:parseXml()} that can be used to parse and inject valid Word XML into the document.

Describe alternatives you’ve considered As an alternative, a configuration option could be provided to not escape XML that is passed to fields in the template.

Additional context I work on a team where this would be very useful. Specifically, we would like to use it to create the XML required to render complex nested lists of varying depths.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:5
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
steevepaycommented, May 11, 2020

Hi @exzizt, sorry for the delay For now, the only solution is to use the flag canInjextXML=true. It may result in some overflow and the final report may appear invalid because it does not follow the Open XML specifications. The team is working on rendering HTML into templates, and I think it will be a much better solution to inject complex content into the document.

If you don’t mind, can you share a report you have generated with a list? I would like to investigate on my side. My email is available on my Github profile.


For those who want to inject XML into a template, it is possible to create a custom formatter:

const carbone = require('carbone');

function injectXML (data) { // data = d.myCustomXML
  if (data) {
    return data.replace(/&amp;/g, '&').replace(/&lt;/g, "<").replace(/&gt;/g, ">");
  }
  return "";
}

//flag used by the builder function to inject raw XML
injectXML.canInjectXML = true;

carbone.addFormatters({
  // this formatter can be used in a template with {d.myCustomXML:injectXML()}
  injectXML
});
1reaction
steevepaycommented, Apr 17, 2020

Hi @exzizt, thank you for reaching us! I will discuss about it with the team and come back to you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Understand when and how to use Office Open XML in your ...
Start with the APIs available through the WordApi requirement sets to see if they provide what you need. For an example, see the...
Read more >
Word Document Templates that use FetchXML for Complex ...
Word Document Templates that use FetchXML for Complex Data Retrieval · Retrieve your data · Create Word Template in CRM · Populate Word...
Read more >
Remote Template Injection
Remote Template Injection ... Microsoft Word has a feature where a user can create a document with a template. Whenever a Word document...
Read more >
A Complete Guide to Creating and Populating Word ...
We're effectively naming parameters on our template in preparation for us opening this template in Power Automate. Add all of these controls and ......
Read more >
News.mscrm-addons.com Blog | The "Insert as Document"
This article outlines how to use the “Insert as Document”-functionality within the “Insert”-button in Open Office XML templates (.docx).
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found