Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Info
titleQuery example

select mc.firstname,mc.lastname,mc.account_no from m_client mc
where mc.activation_date between ${startdate} and ${enddate}

 

     

7. Add Global scripting 

Image Removed

Copy this content into it

// This is a template to demonstrate the existing functions
// you can use in a global data-source script. All functions and
// global variables you define here will be available for the
// all query scripts.
//
// Feel free to delete any function you don't use.
//
// you can process scripts via
// scriptHelper.eval("println ('Hello World');", "ECMAscript");
//
// or your can load your own ECMA/JavaScript files and execute them via
// scriptHelper.evalFile ("/your/file/here.js", "ECMAscript");
//
// both inline scripts and files will be executed in the global context -
// any function or variable defined there will be available globally.
//
// The following global variables exist by default:
// resourceManager : The ResourceManager can be used to load files
// contextKey : ResourceKey the context key points to the prpt-bundle
// dataFactory : The current datafactory instance
// configuration : The current report configuration
// resourceBundleFactory : Access to translations and locale information

function init(dataRow)
{
// place all initialization logic here. This is the right space to
// prepare complex lookup tables or to fill global variables.

// this method is called once when the data-source is first used.
var tenantUrl = dataRow.get("tenantUrl");
var user = dataRow.get("username");
var password = dataRow.get("password");
dataFactory.getConnectionProvider().setProperty("user", user);
dataFactory.getConnectionProvider().setProperty("password", password);
dataFactory.getConnectionProvider().setUrl(tenantUrl);
}

function shutdown()
{
// place all shutdown logic here. If you use any persistent resources
// like files or connections make sure you close them here.

// this method is called once during the data-source shut-down. It
// will be called after all query scripts have been shut down.

}

8.  Once you create executable Sql Query, you may have to add parameters if required. In order to embed Pentaho Report to MifosX, At least you have to create 3 parameters which are passed to MifosX, namely

...

Basically these three parameters are required to embed Pentaho Report in MifosX. Similarly,  you can define more parameters as per requirement of the report. 

98. Once you add the parameters, you need to check whether the report is working fine in the pentaho environment. First,  You need to add the Report fields into 'Details' section of the pentaho environment. In our example, the fields 'firstname', 'lastname' and 'account_no' of the clients are added. In order to add them you need to drag each field in 'Details' section of the pentaho environment as shown in following two screenshots.

...

                                                         

 10 9.  Next you need to click on 'Run' button and choose appropriate format for the report.

    

 11 10. Once you 'Run' the report by choosing appropriate format, the following window should open where you enter the parameters and generate the report. (In this case, PDF is selected)

   

1211.  If you click on 'Ok' button and PDF is generated, it means Pentaho Report is created successfully.

12. Add Global scripting, once you are done with all the design and testing. Before you save the report you need to add global scripting. 

Image Added

Copy this content into it

// This is a template to demonstrate the existing functions
// you can use in a global data-source script. All functions and
// global variables you define here will be available for the
// all query scripts.
//
// Feel free to delete any function you don't use.
//
// you can process scripts via
// scriptHelper.eval("println ('Hello World');", "ECMAscript");
//
// or your can load your own ECMA/JavaScript files and execute them via
// scriptHelper.evalFile ("/your/file/here.js", "ECMAscript");
//
// both inline scripts and files will be executed in the global context -
// any function or variable defined there will be available globally.
//
// The following global variables exist by default:
// resourceManager : The ResourceManager can be used to load files
// contextKey : ResourceKey the context key points to the prpt-bundle
// dataFactory : The current datafactory instance
// configuration : The current report configuration
// resourceBundleFactory : Access to translations and locale information

function init(dataRow)
{
// place all initialization logic here. This is the right space to
// prepare complex lookup tables or to fill global variables.

// this method is called once when the data-source is first used.
var tenantUrl = dataRow.get("tenantUrl");
var user = dataRow.get("username");
var password = dataRow.get("password");
dataFactory.getConnectionProvider().setProperty("user", user);
dataFactory.getConnectionProvider().setProperty("password", password);
dataFactory.getConnectionProvider().setUrl(tenantUrl);
}

function shutdown()
{
// place all shutdown logic here. If you use any persistent resources
// like files or connections make sure you close them here.

// this method is called once during the data-source shut-down. It
// will be called after all query scripts have been shut down.

}

 

13. You need to save the report with '.prpt' extension. In order to do it, Just go to the 'File' menu and click on 'Save' button. 

...