Book a Demo

Author Topic: RunReport from script  (Read 7500 times)

ja1234

  • EA User
  • **
  • Posts: 37
  • Karma: +0/-0
    • View Profile
RunReport from script
« 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?

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: RunReport from script
« Reply #1 on: January 05, 2017, 02:34:34 am »
At a guess: the GUID must be formatted with prj.GUIDtoXML (guid)

q.

ja1234

  • EA User
  • **
  • Posts: 37
  • Karma: +0/-0
    • View Profile
Re: RunReport from script
« Reply #2 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

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13505
  • Karma: +572/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: RunReport from script
« Reply #3 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


Geert

ja1234

  • EA User
  • **
  • Posts: 37
  • Karma: +0/-0
    • View Profile
Re: RunReport from script
« Reply #4 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


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.
« Last Edit: January 06, 2017, 12:54:32 am by ja1234 »

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13505
  • Karma: +572/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: RunReport from script
« Reply #5 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

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: RunReport from script
« Reply #6 on: January 05, 2017, 10:37:00 pm »
I just tried the above snippet and had no issue creating a report.

q.

ja1234

  • EA User
  • **
  • Posts: 37
  • Karma: +0/-0
    • View Profile
Re: RunReport from script
« Reply #7 on: January 06, 2017, 12:56:24 am »
Yes the snippet works, putting it out there for anyone who might have the same problem.