Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: ja1234 on January 05, 2017, 01:48:43 am

Title: RunReport from script
Post by: ja1234 on January 05, 2017, 01:48:43 am
This code does NOT >:(  work:

Code: [Select]
var prj = Repository.GetProjectInterface();
prj.RunReport("{GUID}", "test","C:\\diagram_export\\3.rtf");

where test is a template in User Templates

I simply have hardcoded something in the "test" file and I want to export it into a rtf. Ideas why it is not working?
Title: Re: RunReport from script
Post by: qwerty on January 05, 2017, 02:34:34 am
At a guess: the GUID must be formatted with prj.GUIDtoXML (guid)

q.
Title: Re: RunReport from script
Post by: ja1234 on January 05, 2017, 03:32:55 am
Code: [Select]
       
        var prj = Repository.GetProjectInterface();
        var id = Repository.ProjectGUID;
var xmlID = prj.GUIDtoXML(id);

prj.RunReport(xmlID , "test","C:\\diagram_export\\3.rtf");
   
Thanks. Tried it, still not working. Everything that I put as arguments is simply ignored - the document generation window triggers with a totally different template name and path.  :o :o :o
Title: Re: RunReport from script
Post by: Geert Bellekens on January 05, 2017, 04:20:06 am
It helps if you read the explanation in the manual.
Simply guessing and throwing random stuff at the operations usually doesn't work.

http://www.sparxsystems.com/enterprise_architect_user_guide/13.0/automation/project_2.html
 (http://www.sparxsystems.com/enterprise_architect_user_guide/13.0/automation/project_2.html)

Geert
Title: Re: RunReport from script
Post by: ja1234 on January 05, 2017, 08:39:24 pm
It helps if you read the explanation in the manual.
Simply guessing and throwing random stuff at the operations usually doesn't work.

http://www.sparxsystems.com/enterprise_architect_user_guide/13.0/automation/project_2.html
 (http://www.sparxsystems.com/enterprise_architect_user_guide/13.0/automation/project_2.html)

Geert

Probabilistic programming and it can sometimes work , especially when the documentation is ambigous ;)

so, here's the deal:

- assume a package, that does not have the stereotype MasterDocument
- you want to RunReport on that package, from a script

Select the package in the Project Browser Window   

then in your script add:

Code: [Select]
var currentProject = Repository.GetProjectInterface; //gets current project
var id = currentSelectedElement.PackageGUID; //gets currently selected package GUID
currentProject.RunReport(id, "Your_Custom_Template_Name", "C:\\exports\\1.rtf");

where Your_Custom_Template_Name is saved in Resources/User Templates

This works.
Title: Re: RunReport from script
Post by: Geert Bellekens on January 05, 2017, 09:35:00 pm
I'm sorry, from your response I can't make out if you have solved the issue or still have a problem and you are requesting help.

Geert
Title: Re: RunReport from script
Post by: qwerty on January 05, 2017, 10:37:00 pm
I just tried the above snippet and had no issue creating a report.

q.
Title: Re: RunReport from script
Post by: ja1234 on January 06, 2017, 12:56:24 am
Yes the snippet works, putting it out there for anyone who might have the same problem.