Author Topic: Problems with Templates and Scripts  (Read 3194 times)

emiliano.davila

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Problems with Templates and Scripts
« on: September 29, 2021, 05:26:22 am »

Hi, we are working with templates and scripts for report generation, but we are getting a problem when trying to get the linked document of an element.

The script is as follows:



And the template is as follows:



The fragment "Template - DER Short DocVinc" refers to the script mentioned above. When generating the report we get the following error:



Any idea how to fix it?

philchudley

  • EA User
  • **
  • Posts: 669
  • Karma: +16/-0
  • UML/EA Principal Consultant / Trainer
    • View Profile
Re: Problems with Templates and Scripts
« Reply #1 on: September 29, 2021, 07:00:57 am »
A script driven fragment has to return an XML document, and a linked document is not in XML format.

Not sure why you are using a script, since the element section, once expanded has a linked document section, which when selected will insert the contents of the linked document.

Remove the template fragments.
Expand the element section (the checkboxes)
Select Linked Document (If I remember correctly there are no fields to insert, just the linked document section

Save the template and regenerate.

Phil
follow me on Twitter

@SparxEAGuru

emiliano.davila

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Re: Problems with Templates and Scripts
« Reply #2 on: September 29, 2021, 10:25:23 pm »
We are using a script because to generate the report we use the elements of a diagram, and these elements do not have more properties to add.



We made a script to return the files of the diagram elements, but with the linked documents we have not been able to do it. As I understand, the xml that the template receives has a specific format. Is there any way to transform the linked document into an xml with that format?

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 11314
  • Karma: +422/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Problems with Templates and Scripts
« Reply #3 on: September 30, 2021, 03:38:03 am »
No, it doesn't work that way.

But you can use a Document script template and return the RTF code as is.
See https://sparxsystems.com/enterprise_architect_user_guide/15.2/model_publishing/document_script_fragment.html

Or else use a virtual document to reference each of the used elements individually.

Geert

emiliano.davila

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Re: Problems with Templates and Scripts
« Reply #4 on: September 30, 2021, 10:53:25 pm »
Thank you both very much!