Author Topic: Using DocumentGenerator in Document Fragments  (Read 5575 times)

stevesavage

  • EA User
  • **
  • Posts: 119
  • Karma: +4/-0
    • View Profile
Using DocumentGenerator in Document Fragments
« on: November 02, 2016, 04:05:11 am »
I know this has been around since 12.1, but I'm finally getting around to experimenting with this now, and it's showing a lot of promise of making more complex documents.
Has anyone else been experimenting with this?

Under Document Options -> Custom Query you can select Document Script, then select the script from your script library with the function you want to call (or select a script in the language you want to use, then write the function in the provided area)

E.g. I selected: "EAConstants-JScript"

Then defined my function in the provided area:

function createRTF(inElementID)
{
  var local = {};
  local.selectSQL = "SELECT t_object.Object_ID FROM t_object .....";
  local.selectedElements = Repository.getElementSet(local.selectSQL,2); // could also use Repository.SQLQuery and then pull from the XML
  local.documentGenerator = Repository.CreateDocumentGenerator();
  local.documentGenerator.NewDocument("");
  for ( local.i = 0 ; local.i < local.selectedElements.count ; local.i++ )
  {
    local.element = local.selectedElements.GetAt(local.i);
    local.template = "VD-DMD-03-Data Dictionary (EN) Select-" + local.element.Stereotype;
    Session.Output(local.element.Name);
    local.documentGenerator.DocumentElement(local.element.ElementID,1,local.template);
  }
  return local.documentGenerator.GetDocumentAsRTF();
}
createRTF(#OBJECTID#);

Anyway, just playing with it now, will write a blog entry when I have more time.
Steve.
« Last Edit: November 02, 2016, 04:37:46 am by stevesavage »

mnika1

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: Using DocumentGenerator in Document Fragments
« Reply #1 on: August 27, 2019, 11:44:25 pm »
Hi,
I know this topic is old but I would love to hear about examples of this (more complex documents using DocumentGenerator).  Document generation from creating regular custom templates in EA seems laborious. Did you ever write that blog post?

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13387
  • Karma: +566/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Using DocumentGenerator in Document Fragments
« Reply #2 on: August 28, 2019, 01:40:48 am »
Have you read my article about document generation: https://bellekens.com/2015/11/12/tutorial-generate-complex-documents-from-enterprise-architect-with-a-two-step-semi-automated-approach/

I've tackled a lot of complex document generation requirements using this technique.

Geert

mnika1

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: Using DocumentGenerator in Document Fragments
« Reply #3 on: September 03, 2019, 10:39:49 pm »
Thank you so much, Geert :)