The community of Analytics developers are invited to follow and participate in the developer network.
OpenText technical experts collaborate with supported customers and partners in the Magellan product area.

BIRT-set a Data element as a global variable

Hello guys,
I'm working on a report where i have to set data elements stored in a table as global parameters so that i can use them in every script. as long as i know i must use the following method:

reportContext.setPersistentGlobalVariable (name_of_variable,value_of_variable);

what i want to know is where to set this command. for example the data element that i want to set as global is stored as colomun binding in a table and named Max1 and how can i call this global parameter back
and how can i do the same thing when the data element is stored in a dataset?

thanks in advance


  • I recommend using hidden parameters instead of global variables. Parameters are easier to reference and handle data types better than global variables. Attached is an example that gets values from the table and saves them to parameters. The parameter values are displayed beneath the table. Below the parameters is a Text element and a label element that get parameter values in code and display them.

    Jeff F.
    Sr. Technical Support Specialist
  • edited August 6, 2019

    hello Jeff,
    thank you very much. This would really help me. but the problem is that after i save a value(stored in a table) in a parameter, i can't retrieve this parameter in my chart script. What i'm trying to do is that i'm saving a Max value in a parameter which works, and then call it in my chart script and set this parameter as max scaling for my y-axis. Please see the following pic.

    thanks in advance

  • I feel like this could be accomplished much easier/or differently than presented in the post.
    However to get the parameter value into the chart scripting, you need to pull it via the 'icsc' call.
    Try this code example:

    function beforeGeneration( chart, icsc )
    Matthew L.
  • Hello Matthew L.
    Thank you very much for your help
    If you have any idea that is easier than my thought, i would be grateful.

    Regarding your example, I treid the code you posted, but no work. it does not recognise the getParameterValue Method. please see the displayed error in the pic

    thanks in advance

  • Looking at the screenshot I would assume your designer isn't fully installed or is not completely loading.
    Can you post an image of the Help -> About box for your designer?
    This will help determine your build number along with information regarding on what modules didn't load.
    Side question: Did you install the designer in a folder outside of "C:\Program Files\" (such as c:\BIRT) and are launching BIRT with the right click menu "Run as administrator" option?

    Matthew L.
  • edited August 6, 2019

    when i click on **Help-->about **it displays nothing but when i click on Inatallation details, it gives some info about the version. Please see the following pic

    my installation folder is : C:\SVN\validation_org\90_Tools\BIRT\birt\BIRT.exe

    thanks in advance

  • Looks like your using the "RCP" version of BIRT.
    I've never had much luck with that version (or the Framework version) as I'm always missing some dependencies (could also be why the Help -> About box doesn't show any modules loaded).
    Can you try installing the "All-in-One" version?

    Matthew L.
  • I will download the all i one version and will report if it makes a change. But thank you so much.
    I have one other question. Actually, I'm so happy to find a forum that is still alive or from which i can get help wih BIRT, because as you know BIRT is no longer being developed so far i see.

    I'm working on a report for my company. The report affords advanced knowledge with BIRT, specifically with Chart Engine. I mean I've got a task where i must display certain data stored in Data set or Table, Whatever, and i must display this data in a bar chart in a way that i cannot do it direct from chart wizard. So if i post my report here with full explanation of how the data must be displayed. So my question is :Would i get full support on this page? or is there somewhere else where i can get full support ?

    I might seem a little bit in a rush but i have been working on this report for almost three months and i've started to lose some hair on this.

    Thank you so much

  • Regarding your suggestion of installing All-in-one version i did it and seem everything to be okay but still doesn't find the getParameterValue. Please see the following pic

    thanks in advance

  • The context menu is helpful, but cant show you everything possible.
    Did you try my suggested code anyway?

    The getExternalContext() call gives you 'getObject' or 'getScriptable' objects.

    In my previous code example, you can use .getObject or .getScriptable as they both return a 'java.lang.Object'

    Then using the object you can get .getParameterValue:

    I've just tested this on the latest All-in-One 4.8.0 OS build and it still works for me.

    As for your previous questions:
    I can't speak for the OpenSource (OS) versions of BIRT however the professional (commercial) versions of BIRT is still in development.
    As for full support on your project, the forums usually don't provide full support on projects.
    The forum community can try to answer specific issues that come up.
    As for posting your report design, I would definitely remove any database info and user/pass from the design before posting.
    However, its better to create a working example (using classic models if possible) that focuses on the topic issue only.
    This way forum users can download and run the example which helps to find a solution without digging through a complex report or building their own example.

    Matthew L.
  • edited August 6, 2019

    Hi Matthew;
    I've tried your code, but as i say after i call getScriptable method i can't call or see the getParameterValue method, although i've tried this on All-in-one version. I'll show you what I've done

    However, when i type your code regardless of not showing the GetParameterValue() after getScriptable() as predicted, i get again the following error

  • Looking at your screenshots, I would try closing the browser tabs (or clearing the cache).
    My assumption is that the previous invalid runs are storing invalid data in the cache.
    Attached is an example I created and screenshot of it working.

    Matthew L.
  • Hi Matthew,
    I have deleted everything in the report(datasets, parameters,variables,,,,etc) and left only the chart with it's table. it works!!!!. So i don't know what i have deleted that which made it works. What do you think is the problem?
    Thanks in advance

  • Hello Matthew,
    it works, I have set the chart and the table out of the Grid(that contains the chart and table) and it works. Honestly i don't know what does the Grid have to do with it but however thank you so much for your help. I'll post full working code.

    * Called before generation of chart model to GeneratedChartState.
    * @param chart
    * Chart
    * @param icsc
    * IChartScriptContext

    function beforeGeneration( chart, icsc )

    xAxis = chart.getBaseAxes()[0];
    yAxis = chart.getOrthogonalAxes( xAxis, true)[0];
    xscale =xAxis.getScale();
    yscale = yAxis.getScale();
    min = NumberDataElementImpl.create(icsc.getExternalContext().getScriptable().getParameterValue("myMin"));
    max = NumberDataElementImpl.create(icsc.getExternalContext().getScriptable().getParameterValue("myMax"));
    xscale.setStep (icsc.getExternalContext().getScriptable().getParameterValue("step"));


  • edited August 7, 2019

    Hi Mathew,
    I will post the presentation of my second problem also here, because it's related to the previous solved problem.

    in the following report i have a chart that has dynamic Min/Max value (retrieved from the table).
    I have additionally added a dynamic step value as the task requires. The chart displays on the x-axis the data row["value"]. Under this data element there are many values (up to four and can be more for different data). the y-axis displays a value which is not of interest.

    What i'm trying to do is:

    I'm trying to make chart display on the y-axis how many values from row["value"] exist in each Interval or step (Note: the step is set dynamically using chart script). To understand this better please see the following pic:

    I believe this can be done but this is honestly out of my experience. I think i should start from BeforeDrawSeries event function but don't now how.
    I have found a basic chart API where i can probably modify the x-category and Value-y but still the question is. how and where i should prepare the data in order to be able to display them as shown above.

    I've posted therefore a draft example with out any data base or usernames as you've told me in order to make it easier.
    Note that I'm using xml-data source as the task requires. Please view the report using HTML to avoid happening an unknown error.

    I would be really thankful if you or someone else could share there thoughts or have solution to this

    thanks in advance

Sign In or Register to comment.