Pentaho

 View Only
  • 1.  Pentaho CDE

    Posted 07-04-2023 07:44
    Hi all, I'm new to Pentaho, is it possible in PreExecution to set dinamycally dataSource?
    Please help me. Thanks in advance.


    ------------------------------
    Marco Voto
    Systems Engineer
    GPI
    ------------------------------


  • 2.  RE: Pentaho CDE

    Posted 07-09-2023 13:08

    Marco,

    if you need to be able to switch between two or more predefined datasources, you can try something like the following in pre-execution:
    function f()
    {
        this.chartDefinition.dataSource = (condition) ? "myds1" : "myds2";

    where "myds1" and "myds2" are datasources defined in the Datasources Panel.

    If you need to define dynamically the whole datasource definition, I can't help you: I don't know if it is possible.

    Regards
    Luciano



    ------------------------------
    Luciano Donazzolo
    Systems Engineer
    none
    ------------------------------



  • 3.  RE: Pentaho CDE

    Posted 07-10-2023 11:41

    Hi Marco,
    I have solved it using a trick.
    First, i use a button to confirm the entered parameters.
    In the "expression" property of the button, i perform a switch/case statement so that, based on the selected parameters, a different data source is dynamically selected. I assign the name of the data source to a parameter (in my case, I decided to name the parameter "genericSQL" and the variable dataS contains the name of the datasource selected in the switch/case), which is updated using a firechange, like this: dashboard.fireChange("genericSql", dataS)
    I only needed to display the data in a table, so i set empty the name datasource in the datasource property and  in the pre-execution property, i specify the selected data source like this:

    function f() {
      # some other code here

      this.chartDefinition.dataSource = this.dashboard.getParameterValue('genericSql');



    ------------------------------
    Carl Messner
    Administrative Assistant
    MCSF
    ------------------------------