Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Messages - RWHurra

Pages: [1] 2 3
If I use the same template directly on an element (without document script) it works like a charm.

With document script, nothing in child elements.

Bug or do I have the wrong approach?


I use a document script to send elements to the document generator. In my template I have Child Elements ticked.

However no child elements are reported. I tried to send the child elements to the report through the document script as well but it just report it as regular elements, not as child elements to the element in focus.

Any idea what's going on?


I think I solved this... almost.

I connected the Document Artifact to the package. With some document scripts I look for the connectors of the package and find the Document Artifact, and send it to RTF through the docGenerator. However, I think my Document Artifact is too big?

I found this thread:

how to increase script fragment size?

It's and old thread.. Is there a fix for this?

Thank you for all the help!

 I have another question regarding using a generated report as attachment or appendix in another report. I have created another thread for this, feel free to have a look!

Thanks again!

New thread


I have generated a report which traces to a document artifact.

Can I use this document artifact as a appendix in another generated report? Can I somehow make this document artifact a linked document to a package? That would make it really easy.

Thank you!

From DBError.txt:
Code: [Select]
2017-10-30 09:23:22
Microsoft OLE DB Provider for SQL Server [-2147217900]

Invalid column name 'undefined'.

SELECT o.ea_guid AS CLASSGUID, o.Object_Type AS CLASSTYPE, o.Name AS Name, d.Name AS Diagram, d.Diagram_ID AS DiagramID
FROM t_object o
INNER JOIN t_diagramobjects do ON do.Object_ID = o.Object_ID
INNER JOIN t_diagram d ON d.Diagram_ID = do.Diagram_ID
WHERE o.Object_ID = undefined
ORDER BY Diagram

It seems that objectID = undefined. Although, as I mentioned earlier it seems to run the script twice. Once with objectID = undefined and once with correct objectID, since I get the correct report output.

I have no idea how to backtrack this error. Is it in a script, function, template or fragment? :o

Thanks for your help!

The error is a database error, not an XmlDom error, so it should be something on the database side.

EA does some pre-processing with the SQL's we send trough, so it might be related to that. I would really look into the dbError.txt and what you can see on the profiler.

Might not be related, but if you are only interested in the DiagramID, why are you returning all those other fields in your query?


Thank you Geert.

I can't access %appdata%, I don't have Sparx Systems folder locally. I will contact the IT-dep.

I just wanted to see what objects I get out, and I know that with the names not the IDs. I can remove them, do you think it will make a difference though?

Look into %appdata%\Sparx Systems\DBerror.txt or turn on the profiler on your SQL server.

That should given you some more info on the error you are getting. It will probably be something other then this actual query.


I isolated the problem to the function where I call the SQL-query and I think I know the problem.

I tried to print the result from the query and actually got two outputs:

Code: [Select]
Script Trace - <?xml version="1.0"?>
<EADATA version="1.0" exporter="Enterprise Architect">

Code: [Select]
Script Trace - <?xml version="1.0"?>
<EADATA version="1.0" exporter="Enterprise Architect">
<Dataset_0><Data><Row><CLASSGUID>{xx}</CLASSGUID><CLASSTYPE>type</CLASSTYPE><Name>name</Name><Diagram>diagram name</Diagram><DiagramID>xx</DiagramID></Row></Data></Dataset_0></EADATA>
My guesss is that the first part yields the error since "//Row/DiagramID" can't be found.

Any thoughts about this?

I did not have this kind of output before though..? Don't know what might of happened.

Code: [Select]
!INC Local Scripts.EAConstants-JScript
!INC EAScriptLib.JScript-XML

function getDiagramOccurences( objectID /* : ElementID */ ) // Output: Array
var SQLresult = Repository.SQLQuery("SELECT o.ea_guid AS CLASSGUID, o.Object_Type AS CLASSTYPE, o.Name AS Name, d.Name AS Diagram, d.Diagram_ID AS DiagramID FROM t_object o INNER JOIN t_diagramobjects do ON do.Object_ID = o.Object_ID INNER JOIN t_diagram d ON d.Diagram_ID = do.Diagram_ID WHERE o.Object_ID = " + objectID + " ORDER BY Diagram");

var DOMDoc = XMLParseXML(SQLresult);
var DiagramIDs = XMLGetNodeTextArray( DOMDoc, "//Row/DiagramID" );

return DiagramIDs;

I would write it like this:
Code: [Select]
"SELECT o.ea_guid AS CLASSGUID, o.Object_Type AS CLASSTYPE, o.Name AS Name, d.Name AS Diagram, d.Diagram_ID AS DiagramID
FROM t_object o
INNER JOIN t_diagramobjects do ON do.Object_ID = o.Object_ID
INNER JOIN t_diagram d ON d.Diagram_ID = do.Diagram_ID
WHERE o.Object_ID ="  + ObjectID +
ORDER BY Diagram"

I've never had the error you mentioned, maybe the above version doesn't have the issue.


Thank you for your input! Your query works good, although I get a similar error:

The generated report still looks good!

I have managed to select diagrams with SQL query, collect the diagramIDs, select diagrams of interest with IF, send it to template with document script.

It works fine, I generate the report I want but I get this strange error code.

My SQL query is:

Code: [Select]
"SELECT t_object.ea_guid AS CLASSGUID, t_object.Object_Type AS CLASSTYPE, t_object.Name AS Name, t_diagram.Name AS Diagram, t_diagram.Diagram_ID AS DiagramID

FROM t_object, t_diagram, t_diagramobjects

WHERE t_object.Object_ID LIKE " + objectID + " AND t_diagramobjects.Object_ID = t_object.Object_ID AND t_diagramobjects.Diagram_ID = t_diagram.Diagram_ID

ORDER BY t_diagram.Name"

I get the correct result, but that annoying error message.

Anyone know why?

Thank you for your help!

I did as Uffe said; SQL Query and matching the ID's.

I now get my data as following rows:
<Row><CLASSGUID>{xx}</CLASSGUID><CLASSTYPE>Type</CLASSTYPE><Name>Element name</Name><Diagram>Diagram name</Diagram><DiagramID>xx</DiagramID></Row>

My first problem is to parse this data from the XML-format.

I tried to use JScript-XML and the function XMLGetNodeText/XMLGetNodeTextArray with no success.

Also I do not know which of the following solutions are best.

I want to be able to chose which diagrams to include in the report. I believe it is easiest to choose diagram based on their names since we have an abbreviation in the end of the diagram names. However, when sending the diagram to the report I am more interested in the DiagramID.

Should I create a new object? and .id? Should I have two arrays? One with string one with int? How would you do this?

I appreciate all your help!

I manage to fetch the first entry of DiagramID through

   var DOMDoc = XMLParseXML(SQLresult);
   var DiagramIDs = XMLGetNodeText( DOMDoc, "EADATA/Dataset_0/Data/Row/DiagramID" );

However, I (almost) always has several rows. I can't get XMLGetNodeTextArray to work. Or should I somehow loop XMLGetNodeText?

Dunno why I didn't get this to work before but

   var DOMDoc = XMLParseXML(SQLresult);
   var DiagramIDs = XMLGetNodeTextArray( DOMDoc, "//Row/DiagramID" );

works fine!

I also realized the problem Bellekens pointed out; With regular script or SQL fragment you can't output diagram images.

But if I set this up as Document Script I can choose what to send to the built in section editor?

I know I can use the documentation section

Package: Element: Usage: Diagram

but I can't exclude diagrams from the section. Or can I?

Automation Interface, Add-Ins and Tools / Element Usage list through API
« on: October 04, 2017, 07:46:18 pm »

I am creating some documentation/reports via script fragments. I would like to show specific diagrams. My first idea was to iterate through the element usage list (ctrl+u) and send diagrams to the report based on the name of the diagram.

However I didn't find anything like ctrl+u in the API, and didn't find it googling/searching the forum either. Does anyone know a method to create a collection with the diagrams like ctrl+u?

Is there a better approach to select specific diagrams?

Thank you!


I have a fragment in my document generator which finds element of interest with a SQL query. When I print the element's note the hyperlink is printed as a string instead as a hyperlink:

Code: [Select]
<a href="$element://{3D79297A-4128-4fdd-9070-3BA328E674F0}"><font color="#0000ff"><u>My element of interest</u></font></a>
This is no problem when inserting the note with the pre-built sections. Can I convert this html-string to an actual hyperlink in my documentation?

Thank you!

I solved the element image with pasting the image in a linked document. I did not manage to solve the table issue.

Pages: [1] 2 3