Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
select query into a variable
ajunuthula
Hi,
My select statement extracts a value from the table in the database and stores it into a variable.
Now depending on the variable value using if statements, some action must be performed.
Can you help me how to assign the extracted value into a variable in html/javascript or is there any other way.
Thank you,
Aparna
Find more posts tagged with
Comments
mwilliams
So, your dataSet returns a single value and you now want to use this value somewhere in your report? You can store the value into a persistentGlobalVariable in your onFetch script and use it in your report. What are you trying to do with it?
ajunuthula
Yes.
Once I store the value in a variable, depending on the value(if statements), I will be running different reports.
For e.g, if the value is 1, then report1 will be opened, if 2 report 2.........
What is a persistentGlobalVariable? and how can I use it?
Thank you.
mwilliams
Let me figure out exactly what you're doing before I suggest anything further. I'm a little confused again after your last post. You don't want to do something in your report based on the returned value, you want to execute a certain report based on the value? What is the value? Is it the report name? Let me know.
ajunuthula
Sorry for the confusion.
I will extract a value from the table in the database (data set) and store it into a local variable.
Now I will try to check for the value of the variable using if statements in java script(gets executed on click of a button in the report) and then other reports must be opened based on the value. here the extracted value is an ID, so depending on the id, reports must be opened. Each id is related to each report.
I am not doing anything in the current report based on the value, just open other reports based on the value.
let me know if this helps.
Thank you.
mwilliams
I see. If you're just needing a link to open a report based on this value, you could bind a text box to your dataSet and use html and BIRT dynamic text, <value-of>, tags to create the URL to your other report.
ajunuthula
I am not sure how to bind the text box to data set.
so, Can I use something like
if (<VALUE-OF>params["node"]</VALUE-OF> == 11) in my java script?
Also, can you brief me on a persistentGlobalVariable , I might need it later where I will have to do something with the value.
Thank you.
mwilliams
You'd select the text box and then go to the binding tab in the property editor and choose the dataSet. I thought the value came from the dataSet? Does it come in in a parameter now?
Any script that is related to the report would be in the <value-of> tags. If you were using the value from the dataSet to create your URL, you could create the entire <a href="url">MyReport</a> HTML code inside the <value-of format=html></value-of> tag and make sure you select HTML from the dropdown at the top of the text box editor and it'd be a HTML hyperlink.
ajunuthula
The value comes from the dataset only.
I was trying something else.
I will try and let you know.
Thank you.
ajunuthula
I have a text box and its binded to the dataset. The code is as below.
<head>
<script type="text/javascript">
<!--
function myPopup1() {
if (<VALUE-OF>"nodeid"</VALUE-OF> == 21498){
window.open( "
http://wisdom.rockefeller.edu:8080/birt/frameset?__report=kruegerlab.rptdesign"
; )
}
}
//-->
</script>
</head>
<body>
<input type="button" onClick="myPopup1()" value="Submit" >
</body>
<BR>
How to check for the value that we get from the dataset named "nodeid"
<VALUE-OF>"nodeid"</VALUE-OF> == 21498
Thank you.
mwilliams
If you've bound your dataSet to the textbox, you'd just put row["yourFieldName"]. You don't need a variable.
ajunuthula
Can you please guide me as what went wrong here in the code.
<head>
<script type="text/javascript">
<!--
function myPopup1() {
if (row["NODE"] == 21498){
window.open( "
http://wisdom.rockefeller.edu:8080/birt/frameset?__report=kruegerlab.rptdesign"
; )
}
else if(row["NODE"] == 20782) {
window.open( "
http://wisdom.rockefeller.edu:8080/birt/frameset?__report=publications1.rptdesign"
; )
}
}
//-->
</script>
</head>
<body>
<input type="button" onClick="myPopup1()" value="Submit" >
</body>
<BR>
The text box is bound to the dataset also.
Thank you.
mwilliams
You didn't use the <value-of> tag. You still have to put that around anything that you get scriptwise from the report. In my last post, I just meant to replace your variable with row["yourField"]. Sorry for the confusion.
ajunuthula
I still have no success, here is my code:
<head>
<script type="text/javascript">
<!--
function myPopup1() {
if (<VALUE-OF>row["nodeid"]</VALUE-OF> == 21498){
window.open( "
http://wisdom.rockefeller.edu:8080/birt/frameset?__report=kruegerlab.rptdesign"
; )
}
else if(<VALUE-OF>row["nodeid"]</VALUE-OF> == 20782) {
window.open( "
http://wisdom.rockefeller.edu:8080/birt/frameset?__report=publications1.rptdesign"
; )
}
}
//-->
</script>
</head>
<body>
<input type="button" onClick="myPopup1()" value="Submit" >
</body>
<BR>
Thank you.
mwilliams
Are you getting an error of any sort?
mwilliams
Try something like:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
<form>
<input type="button" onClick="window.open('<VALUE-OF>if (row["nodeid"] == 21498){
"http://wisdom.rockefeller.edu:8080/birt/frameset?__report=kruegerlab.rptdesign";
}
else if(row["nodeid"] == 20782){
"http://wisdom.rockefeller.edu:8080/birt/frameset?__report=publications1.rptdesign";
}</VALUE-OF>')" value="Submit">
</form>
</pre>
ajunuthula
I tried with the code given by you, but on click a blank window is opened.
Any suggestions please.
Thank you.
mwilliams
Are those the URLs to your report designs? I used it with www.google.com and www.yahoo.com and it worked. Do you have the text box bound to your dataSet so that it has the nodeid binding? Can you attach your report design?
ajunuthula
Those are the URLS to my reports.
I have the text box bound to the data Set with nodeid binding.
Attached is my report design for your reference.
Thank you.
ajunuthula
Its working, have to change nodeid to caps, case sensitive.
Thank you so much for your help.
Have learned something new, how to access the dataset from javascript
I have one more quick question, how can we refresh the current window/report on click of a button.
Thank you.
mwilliams
You're changing the way the code is written in your report. Try using it just like above.
ajunuthula
In my report that I attached, I will be selecting a node at run time (select ctsa button) and then hit submit button, so here after clicking on the button CTSA, the current report must be refreshed (so that new nodeid value reads into data set) and then one should be able to click on submit button.
Is it possible to do so?
Thank you.
mwilliams
Yeah, it should be. You'd just be rerunning the report with different parameters.
ajunuthula
OK.
I have one more requirement, hope you can guide me.
Now moving further, when the CTSA button is clicked, then a new value is written into the database, so when submit is clicked, the new value must be returned back. For now this happens after clicking on the CTSA button and only on refresh manually, the new value is getting into the data set.
Is there some way like when submit is clicked, the current report is rerun/refreshed and then based on the new value, appropriate reports are opened.
For your reference, you can see the report design that I attached earlier.
Thank you.
mwilliams
You should be able to do multiple actions in an onClick event, so you should be able to do both with a single click. Here's an example of onClick doing multiple tasks:
http://www.webdeveloper.com/forum/showthread.php?t=93551