Inserting "Generated on:" date into html

492 views
Skip to first unread message

Wh@localhost Nick Wh

unread,
Mar 12, 2013, 10:23:00 AM3/12/13
to sparx-enterprise-archite...@googlegroups.com
There's lots of great html fragments that can be substituted when generating html reports. �Things like "#CREATEDATE#, "MODDATE" etc. These are for properties of EA objects.

What I want is something that will put the date the html is generated into any page - e.g. on Diagrams, Objects, etc.

It would be great if there was simply a global #TODAYDATE# or similar. �Or perhaps a guru knows how to modify the customisable Javascript that generates html, to put the date into certain places?

I've managed to put some javascript into the 'Body - Diagram' and 'Body - Object' html, but this simply gets inserted as javascript into the html, thus is evaluated every time the pages is displayed - always returning the current date.

Any hints appreciated!
Nick

[original message]

philchudley

unread,
Mar 12, 2013, 11:39:00 AM3/12/13
to sparx-enterprise-archite...@googlegroups.com
Hi Nick

Try adding the following piece of Javascript (without the ") to the required HTML templates


"<script type="text/javascript" >
<!--
document.write(document.lastModified);
// -->
< /script>"

It outputs in American format (or at least if did for me), but you may find some Javascript function to format the date.
this makes sense!

All the best

Phil

[original message]

philchudley

unread,
Mar 12, 2013, 12:02:00 PM3/12/13
to sparx-enterprise-archite...@googlegroups.com
Hi Nick

Here's a better script with formatting into dd/mm/yyyy format

"<script type="text/javascript">
     <!--
     var generated = new Date(document.lastModified);
     var day = generated.getDate();
     var month = generated.getMonth() + 1;
     var year = generated.getFullYear();
     document.write("Generated on: " + day + '/' + (month <= 9 ? '0' + month : month) + '/' + year);
     // -->"

Enjoy!

All best

Phil

[original message]

Wh@localhost Nick Wh

unread,
Mar 12, 2013, 1:23:00 PM3/12/13
to sparx-enterprise-archite...@googlegroups.com
Ah, I had pretty much the same code, but with the line :
new Date();

instead of:
new Date(document.lastModified);

I can see what it should do - looks most promising. �Will confirm tomorrow whether it has worked.

PS I also prefer your more succint code !

Thanks Phil,
Nick

[original message]

Wh@localhost Nick Wh

unread,
Mar 13, 2013, 5:39:00 AM3/13/13
to sparx-enterprise-archite...@googlegroups.com
Thanks Phil,
confirmed - that code works perfectly!

Added it into the 'Body - Diagram' and 'Body - Object' html templates.  This seems to cover pretty much all the web pages we use - certainly enough for support purposes - to know which version of a website people are using.

cheers,
Nick

[original message]

JReed

unread,
Mar 27, 2013, 12:51:00 PM3/27/13
to sparx-enterprise-archite...@googlegroups.com
I'm looking for the same functionality (insert a "generated on" date that won't be updated automatically later), but for RTF reports. �Any suggestions?
[original message]

Paulus

unread,
Mar 27, 2013, 4:43:00 PM3/27/13
to sparx-enterprise-archite...@googlegroups.com
I guess that would be the 'current date' field available from the context menu 'Insert' in the RTF template editor?
[original message]

JReed

unread,
Mar 27, 2013, 5:50:00 PM3/27/13
to sparx-enterprise-archite...@googlegroups.com
That's what I used in the report template to insert the value into the RTF report. but when the report is opened (in Word), the field gets updated automatically.
[original message]

Paulus

unread,
Mar 28, 2013, 4:29:00 AM3/28/13
to sparx-enterprise-archite...@googlegroups.com
I thought it didn't but you're right �:(

If you use script and the EA API to generate the RTF: i use custom data fields in the RTF template (insert->data field) and then the EA api DocumentGenerator.ReplaceField to include variable content. Works as expected.

If you use the RTF generator dialog in EA i think you need to define a project constant for the data field, but then that will have a fixed value so unless you are willing to update that every time you generate a document it won't be of much help.

If you consider scripting RTF generation: i wrote a demo on how to do that in the community resources (http://community.sparxsystems.com/resources/scripts/script-creates-rtf-document-using-documentgenerator-api).

best regards,

Paulus

[original message]
Reply all
Reply to author
Forward
0 new messages