Hello! This is my first post in the ARIS forums.
I am currently exploring ARIS script for reports. I have a request to consolidate several reports into one report. In my OOP experience, I would accomplish something like this by instantiating each report 'class' and then access its properties directly. Ex.:
var oReport_A = <reportObject_A>
var oReport_B = <reportObject_B>
var oReport_C = <reportObject_C>
where <reportObject_x> represents the individual report 'class' for each report I need to work with.
In Aris, I have tried this code:
var Report = Context.getComponent("Report");
var shadowCheck = Report.createExecInfo("Model_Quality/1d6f1570-f61c-11de-04b2-0050569749e7", ArisData.getSelectedModels(), Context.getSelectedLanguage());
But this returns an 'ExecInfo' object. I would like to access a 'Report' object then run the method inside it.
I realize I can use Imported files... to import the report as a reference, but all of the reports I want to import have a common method and I want to call that method exclusive to each report.
Thanks for your help!
Regards,
Rick Beddoe
Hi Rick,
The code you tried is for calling different report from one report. So the report which is being called should have one global function call.
If you import report through Imported Files, you will have to remove any global function call from those reports, and should keep the function names different. Then you can just call the functions in your code.
But i guess you are not looking for above two options. You might want to use the functions in the form of Class and methods. So here is the solution. You will need to import the reports through Imported Files
// Report 1 Report1 = function() { this.Value = "Report 1"; this.CommonMethod = function() { // Code } } // Report 2 Report2 = function() { this.Value = "Report 2"; this.CommonMethod = function() { // Code } } // Import both the above reports in the main report through "Imported Files" // Your code in Main report var g_Report1 = new Report1(); Dialogs.MsgBox(g_Report1.value); g_Report1.CommonMethod(); var g_Report2 = new Report2(); Dialogs.MsgBox(g_Report2.value); g_Report2.CommonMethod();
Regards,
Amol Patil
Thanks Amol,
I removed 'the thing I tried' from my post as I had figured it out. But just to have some closure to the thread, here's what I did:
//this simply reads an XML file and displays it in a browser window
//this is code that already existed in the report and I did not want to add additional code to it directly
function loadXmlFile(test) {
Dialogs.MsgBox(test);
var xmlData = Context.getFile("GUIDs.xml", Constants.LOCATION_COMMON_FILES);
var xReader = Context.getXMLParser(xmlData);
var xDoc = xReader.getDocument();
var xmlOutput = Context.createXMLOutputObject("settings.xml", xReader.getDocument());
return xmlOutput;
}
//this calls the existing code
//the value is passed to the existing code by using the 'property' (this.Value).
//This was 'the thing I tried' and it worked great.
Report1 = function() {
this.Value = "Report 1";
this.CommonMethod = function()
{
loadXmlFile(this.Value).WriteReport();
}
}
//this code can exist in any other report as long as THIS report is referenced
var g_Report1 = new Report1();
Dialogs.MsgBox(g_Report1.Value);
g_Report1.CommonMethod();
Thanks again, Amol
Rick Beddoe
Cargill Aris Technical Analyst
Minneapolis, MN, USA