Displaying label of dynamic parameter list box in report

laiboonh
edited February 11, 2022 in Analytics #1
Hi,
i currently have a report with a report parameter called 'office' which is a dynamic parameter list box sourcing its value from a datasource (a list of offices' details).

The label of my list box is the office's name, value is the office's id.

I can easily display the office's id using params["office"].value but how can i display the office's name?

Many thanks in advance.

Comments

  • mwilliams
    edited December 31, 1969 #2
    Hi laiboonh,

    If by "label of your list box" you mean the display text, you should be able to use params["office"].displayText to get that. Let me know if this is not what you meant. :)
    Warning No formatter is installed for the format ipb
  • chavez_ant
    edited December 31, 1969 #3
    Hello, I am having an issue similar to that described above. I have a parameter named "BusinessGroup", which is a numeric ID number.

    I'd like to display the parameter value in the header. I can get the id number to display all parameters selected using this expression:

    "Business Group(s): " + params["BusinessGroup"].value.join(", ")

    I would like to instead, get the header to display the parameter's 'Display Text', which is set as a field of name DISP_NAME in the parameter settings. I tried using the following expression:

    params["BusinessGroup"].displayText

    Based on your suggestion, but the value comes up as blank. Any thoughts on what may be the issue here?

    Many thanks in advance.
  • chavez_ant
    edited December 31, 1969 #4
    One more tip. I have found that the 'displayText' expression comes out as null only for values that have 'multi-select' enabled. The info is displayed for the one parameter where only one value is allowed to be selected. Let me know if any more info required, thx again.
  • mwilliams
    edited December 31, 1969 #5
    chavez_ant,

    You could try building a string of your "displayText" values in the onFetch method of your dataSet using the actual parameter values to find the correct display text values. I haven't tried it, but I would think you could do this fairly easily. Let me know if you have questions.
    Warning No formatter is installed for the format ipb
  • chavez_ant
    edited December 31, 1969 #6
    Thanks for the tip, it helps! I'm new to BIRT and hadn't scripted an onFetch yet. If you could give such and example of what to enter into the onFetch method of the data set, for this example, that'd be great. I'll be searching for some examples and research doing report scripting in the meantime.
  • mwilliams
    edited December 31, 1969 #7
    What is your BIRT version? I'll take a shot at it in that version.
    Warning No formatter is installed for the format ipb
  • chavez_ant
    edited December 31, 1969 #8
    I've got the latest, 2.6.1, thx!<br />
    <br />
    <blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="70149" data-time="1289337169" data-date="09 November 2010 - 02:12 PM"><p>
    What is your BIRT version? I'll take a shot at it in that version.<br /></p></blockquote>
  • mwilliams
    edited December 31, 1969 #9
    Take a look at the attached report. The report accepts a parameter for CUSTOMERNUMBER. In my report, I want to display the CUSTOMERNAME field. So, I create a comma separated string of the parameters in the initialize method of the report, then I check for the CUSTOMERNUMBER value in the string as I fetch my dataSet rows and replace the values with the other field value that I want, then display the result in a dynamic textbox that is bound to the dataSet so that the dataSet events happen.

    Hope this helps.
    Warning No formatter is installed for the format ipb
  • chavez_ant
    edited December 31, 1969 #10
    That's great, thanks so much! I attempted to run your report and got the following error:

    18004: Cannot get report parameter. Cause: There are errors evaluating script "if (custList.indexOf(row["CUSTOMERNUMBER"].toString()) != null){
    custList = custList.replace(row["CUSTOMERNUMBER"].toString(),row["CUSTOMERNAME"]);
    }
    {1}.
    PARAMETER1=Cannot get report parameter. Cause: There are errors evaluating script "if (custList.indexOf(row["CUSTOMERNUMBER"].toString()) != null){
    custList = custList.replace(row["CUSTOMERNUMBER"].toString(),row["CUSTOMERNAME"]);
    }
    {1}.

    If you get a chance to take a look, would be appreciated. In the meantime, I just set up a query that grabs the first x amount of parameters selected and pulls the names from the database to display them all in one field as a workaround. But I would prefer to get this working with the displayText using the your method.
  • mwilliams
    edited December 31, 1969 #11
    Is that the entire error? I did not get that error, I don't believe. I'll double check though.
    Warning No formatter is installed for the format ipb
  • mwilliams
    edited December 31, 1969 #12
    No, I do not get that error. Not sure why you're getting that error. If you find any further info on that error, let me know.
    Warning No formatter is installed for the format ipb
  • rtruban
    edited December 31, 1969 #13
    <blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="70333" data-time="1289871741" data-date="15 November 2010 - 06:42 PM"><p>
    No, I do not get that error. Not sure why you're getting that error. If you find any further info on that error, let me know.<br /></p></blockquote>
    Michael,<br />
    <br />
    I am having problems recreating this report. Yours works fine, but if I start from scratch it doesn't work. It behaves like the data set 'onFetch' isn't getting called or it is getting called before the report 'initialize'. No matter what 'custList' is populated with CUSTOMERNUMBER's vice what is in the OnFetch. <br />
    <br />
    Is there something that controls the order of events? I am missing something, and it is probably simple... Attached is the report I created. I just did new report, then copied&pasted the data source, data set and scripts from your report. <br />
    <br />
    Any ideas?<br />
    <br />
    Thanks in advance,<br />
    <br />
    Rob
  • mwilliams
    edited December 31, 1969 #14
    Rob,

    Just missing one thing. You need to bind the dynamic textbox to the dataSet so that the onFetch is called.
    Warning No formatter is installed for the format ipb
  • rtruban
    edited December 31, 1969 #15
    <blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="74509" data-time="1299697516" data-date="09 March 2011 - 12:05 PM"><p>
    Rob,<br />
    <br />
    Just missing one thing. You need to bind the dynamic textbox to the dataSet so that the onFetch is called.<br /></p></blockquote>
    <br />
    Thanks! I figured that out after plowing through the XML for each report looking for the difference, brute force approach! But now I believe I have found a bug where this works in 2.6.1 and 2.6.2, but not in BDPro 11. It throws an error when you run the report saying 'there are errors evaluating the script' in the OnFetch. That is taking a report that works in 2.6.1/2 and opening it in BDPro 11 and then it won't run and creating from scratch in BDPro...
  • mwilliams
    edited December 31, 1969 #16
    Can you post the error? I'll have to try this out.
    Warning No formatter is installed for the format ipb
  • rtruban
    edited December 31, 1969 #17
    <blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="74512" data-time="1299705844" data-date="09 March 2011 - 02:24 PM"><p>
    Can you post the error? I'll have to try this out.<br /></p></blockquote>
    <br />
    This is the error in BD PRO 11:<br />
    <br />
    <br />
    <br />
    Message from webpage<br />
    <br />
    18004: Cannot get report parameter. Cause: There are errors evaluating script "if (custList.indexOf(row["CUSTOMERNUMBER"].toString()) != null){<br />
    custList = custList.replace(row["CUSTOMERNUMBER"].toString(),row["CUSTOMERNAME"]);<br />
    }":<br />
    {1}.<br />
    PARAMETER1=Cannot get report parameter. Cause: There are errors evaluating script "if (custList.indexOf(row["CUSTOMERNUMBER"].toString()) != null){<br />
    custList = custList.replace(row["CUSTOMERNUMBER"].toString(),row["CUSTOMERNAME"]);<br />
    }":<br />
    {1}.<br />
    <br />
    OK <br />
    <br />
    <br />
    <br />
    I did open a case with tech support and they acknowledged it is a known bug. Here is the response:<br />
    <br />
    According to the investigation, the report design contains errors:<br />
    <br />
    The user initialize a javascript global variable in the initialize script and use that variable in dataset's onFetch. The dataset is used to create the selection list for the parameter input.<br />
    <br />
    Actually the initialize script is invoked after accept the parameter value while dataset's onFetch is before the parameter input. The error exist in both A11 and 2.6.2. The open source ignore the task errors while the commercial fail the task once there is an error. Therefore, it is the designer behavior, please change your report design and let us know if you need further assistance regarding this case.<br />
    <br />
    ********************************************************<br />
    <br />
    So the question of the day, is there a way to change the report design to get this to work?
  • mwilliams
    edited December 31, 1969 #18
    Rob,

    Add a second dataSet. Having a parameter dataSet and a dataSet that you'll use in the report can handle the issue. This way, the onFetch() of the second dataSet is called after you select the parameters from the parameter dataSet. Take a look.
    Warning No formatter is installed for the format ipb
  • <p>Hi,</p>
    <p> </p>
    <p>I'm very new to BIRT. I am generating a report by programming in full Java, using the Design Engine API. I would like to build a label, whose text would be retrieved from a dataset. For instance, my label (LabelHandle) would display an address, and I would retrieve this address from a dataSet, having a column "address". I need this label to be simply contained in a cell inside of grid, not inside of a table. I have successfully retrieved data from my dataSet in tables, but simply displaying it in a label, I have googled a lot and haven't found how to perform this apparently simple thing.</p>
    <p> </p>
    <p>Thanks a lot for your help!</p>
  • @mwilliams i cannot find your attached report. i have been stuck on this same problem