Author Topic: Is it possible to define variable in document template?  (Read 1899 times)

jankari

  • EA Novice
  • *
  • Posts: 17
  • Karma: +0/-0
    • View Profile
Is it possible to define variable in document template?
« on: March 10, 2017, 03:15:22 am »
I am using EA with shared repository (SQL Server). I have a template that is used for document generation and it is common for all the solutions in the repository. I want to add a variable in the template for "solution name" so that when a specific solution uses the template to generate documentation it can get a pop up or some way to input the solution name at run time. I don't want to use Project Constants or Report Constants as they have a global affect.
Is there any way to do this?
Thank you in advance for your time and input.

Uffe

  • EA Practitioner
  • ***
  • Posts: 1206
  • Karma: +91/-6
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: Is it possible to define variable in document template?
« Reply #1 on: March 10, 2017, 07:21:41 pm »
Hello,


There are ways to do this, depending on how you've set up the document generation process (model document, custom script or hit-F8-to-generate).

Assuming you run the document generation off a package, you can put a tagged value in the package and output that.


/Uffe
My theories are always correct, just apply them to the right reality.

jankari

  • EA Novice
  • *
  • Posts: 17
  • Karma: +0/-0
    • View Profile
Re: Is it possible to define variable in document template?
« Reply #2 on: March 11, 2017, 01:32:59 am »
Thanks Uffe. Yes, I generate document off a package. Yes, I can add a tagged value in that package. How do I output it? I went to document template and there is no option to insert a "tag".
Thanks

Uffe

  • EA Practitioner
  • ***
  • Posts: 1206
  • Karma: +91/-6
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: Is it possible to define variable in document template?
« Reply #3 on: March 11, 2017, 01:43:27 am »
In the template editor, it's in Package -- Package Element -- Tagged Value.

In EA, a package is actually both a package and an element, and it's this "package element" that holds the tagged values.

/U
My theories are always correct, just apply them to the right reality.

jankari

  • EA Novice
  • *
  • Posts: 17
  • Karma: +0/-0
    • View Profile
Re: Is it possible to define variable in document template?
« Reply #4 on: March 11, 2017, 01:59:42 am »
I tried, and realized it puts it in the main document where "package" section starts. I am trying to put it on the first page, that is a static content page, that only has the solution name. The layout of my template is:
header - solution name (this is what I am trying to turn it into a solution level variable)
first page - static content with solution name (this is what I am trying to turn it into a solution level variable)
second page (and onwards) - table of contents
third page onwards - main content loop that recursively builds out the solution documentation.

Thank you

Nairam Serball

  • EA Novice
  • *
  • Posts: 10
  • Karma: +2/-1
    • View Profile
Re: Is it possible to define variable in document template?
« Reply #5 on: March 11, 2017, 07:54:25 pm »
What follows is a short summary of our solution, it will require some work to develop yours but it's worth the effort, trust me.

As Uffe said there's also the virtual document (virtual =master + model document) solution that could help you.
I had the same problem as yours and decided to create master & model documents that all used a common set of templates and an enterprise wide stylesheet.

Master document have specific tagged values  (see http://www.sparxsystems.com/enterprise_architect_user_guide/13.0/model_publishing/create_master_document.html) that can be used anywhere in templates, fragments, and cover pages and even table of contents templates.

We decided to use the "Report name" tagged value to hold our equivalent to your "solution name" in order to automatically populate cover page and page headers/footer in the generated report.

Since setting a master & model documents structure needs a bit of work every time we create a new "solution" (you'll have to create one master/model document structure per solution), we also created our own MDG technology to hold and share the appropriate templates, fragments, stylesheet, coverpages,  and one model pattern with a predefined master/model document. Now, all we have to do is create a new package from pattern wizard using our MDG technology : this creates the new pre-configured master/model document structure in the project browser. Then we set the Report Name tagged value on the master documet, and associate the desired packages to the model documents : report is ready for generation.

Cherry on the cake : using Resource Document (see http://www.sparxsystems.com/enterprise_architect_user_guide/13.0/model_publishing/resource_documents.html) we save the solution-specific configured Report Generation dialog box based on the master/model document and its associated package. This becomes a named "defined document" in the project Ressources : when we need to generate the solution-specific report, we can do a right click on the appropriate resource document and select "auto-generate document" ; everything is pre-configured and the report generates without any other human action (= time for a coffee !).

If we want to generate all the reports for all our solutions, we only have to right-click on "Defined document" (or any sub-group we created) and choose "auto-generate all documents" (= time for a coffe, a sleep, or whatever else !).
 
In conclusion, investigating virtual document + MDG technology + resource documents seems a good roadmap.
It's a hard work to set, but benefits are enormous.

Hope this helps.
Regards.
PS : sorry for my english... I'm French :)

RoyC

  • EA Administrator
  • EA Practitioner
  • *****
  • Posts: 1166
  • Karma: +9/-3
  • Read The Help!
    • View Profile
Re: Is it possible to define variable in document template?
« Reply #6 on: March 14, 2017, 11:13:21 am »
I'd have to point out that there are millions of native English speakers who cannot write English as well as you do. I wish I could write French even half as well.
Best Regards, Roy

jankari

  • EA Novice
  • *
  • Posts: 17
  • Karma: +0/-0
    • View Profile
Re: Is it possible to define variable in document template?
« Reply #7 on: March 15, 2017, 04:29:56 am »
Nairam, thank you very much for sharing the detailed solution! Truly appreciate it! I will try it out. And I concur with RoyC, your English is perfect! :)

Dermot

  • EA Administrator
  • EA User
  • *****
  • Posts: 585
  • Karma: +6/-0
    • View Profile
Re: Is it possible to define variable in document template?
« Reply #8 on: March 15, 2017, 05:03:20 pm »
To follow up on Reply#2 - if the standard EA Report Constants do not cover your needs and you would prefer to use Package Tagged Values, the feature to select a specific Tagged Value is to add the ValueOf() field using the Insert Field context menu option.
That way you can create several Tagged Values (Company, Dept.) and render these in different locations  like in a Table.
See: http://sparxsystems.com/enterprise_architect_user_guide/13.0/model_publishing/tagged_value_sections.html

jankari

  • EA Novice
  • *
  • Posts: 17
  • Karma: +0/-0
    • View Profile
Re: Is it possible to define variable in document template?
« Reply #9 on: March 16, 2017, 12:06:55 am »
Thanks Dermot

natvig

  • EA User
  • **
  • Posts: 53
  • Karma: +7/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: Is it possible to define variable in document template?
« Reply #10 on: March 16, 2017, 08:11:04 am »
I recognise the need that I think jankari is describing. My interpretation is that jankari needs to be able to include a tagged value, defined on the model document itself, into the generated report from that model document. Thus, analogous to Project Constants, but for each model document in a virtual document. The Report Constants setting on a virtual document overwrites any defined tagged values in a n individual model document. Also, it is not possible to include a custom defined tagged value of a virtual document.

With the above functionality it would be possible reduce the number of templates necessary in a model by reusing the same template for many different sections of a report. Consider for example a report with a standard template (look) for all chapters, except that the chapter heading is different for all chapters. With the possibility to include tagged values on the model document itself into the report, we could reuse one single template throughout the virtual document.

/Hans

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 8033
  • Karma: +183/-22
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Is it possible to define variable in document template?
« Reply #11 on: March 16, 2017, 06:29:36 pm »
I agree, we are currently working on a document template (using virtual documents) and we needed different "fixed" headers for the different parts.
Currently they only way we found to make this happen was to make 10 different templates each containing nothing else then the title for that part of the document.
Not that is doesn't work, it just feels a bit stupid to have to maintain 10 different templates just because the "fixed" text of the title is different.

Geert

PeterHeintz

  • EA User
  • **
  • Posts: 629
  • Karma: +38/-14
    • View Profile
Re: Is it possible to define variable in document template?
« Reply #12 on: March 16, 2017, 08:14:45 pm »
Hi Sparxians,
I have not read this thread entirely but it seems to me to go in the same directions as several others (some from me).

Report Constants are just properties of the root package used for the report. So if the solution to use root package properties is already there, a solution to use tags of that root package should not be a big thing.
An even more powerful solution would be to execute custom templates in headers, footers and anywhere outside the package processing.
Best regards,

Peter Heintz