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)
Using dynamic text value to store it in a global variable
anshul9824
<p><span style="color:rgb(90,90,90);font-family:'Source Sans Pro', sans-serif;">Hi ,</span></p>
<p><span style="color:rgb(90,90,90);font-family:'Source Sans Pro', sans-serif;">I have a question. </span></p>
<p><span style="color:rgb(90,90,90);font-family:'Source Sans Pro', sans-serif;">1. Can you tell me the way how to store value from a dynamic text in a global variable ? </span></p>
<p><span style="color:rgb(90,90,90);font-family:'Source Sans Pro', sans-serif;">2. And how to use this variable to hide any grid in the report?</span></p>
Find more posts tagged with
Comments
mwilliams
Since a dynamic text element allows for script in it, you could set your value to a PersistentGlobalVariable with:<br><br>reportContext.setPersistentGlobalVariable("varName",yourValue);<br><br>From there, you could use this value in the onRender of the element you want to hide by calling it with:<br><br>reportContext.getPersistentGlobalVariable("varName");<br><br>Write whatever condition you need and if met, hide the element:<br><br>this.getStyle().display = "none";<br><br>You'll need to be sure to run the report with separate run and render tasks, unless the grid you're wanting to hide is after the dynamic text element. That would probably still work since the variable would be set already.<br><br>Hope this helps.
anshul9824
<p>Hi Michael,</p>
<p> </p>
<p>Please write where to write the code</p>
<p><span style="color:rgb(40,40,40);font-family:'Source Sans Pro', sans-serif;">" reportContext.setPersistentGlobalVariable("varName",yourValue); "</span></p>
<p><span style="color:rgb(40,40,40);font-family:'Source Sans Pro', sans-serif;">as i have tried this javascript in oncreate , in dynamic text box and not able to get the value in the variable.</span></p>
anshul9824
<p>Here is a sample rptdesign.</p>
<p>For e.g. :</p>
<p>There are 2 grids...</p>
<p>grid1</p>
<p>grid2</p>
<p>based on the filter employeenumber =1002, </p>
<p> grid1's dynamic text element "firstname" = 'Diane',</p>
<p> </p>
<p> then i have to store row["firstname"] in a global variable for that in which event do i have write the script to store the value in a global variable and then hide the grid2??</p>
<p> </p>
<p>Thanks...</p>
mwilliams
Here is a modified version of your design. If you click on the first text element in the top grid and click on the script button under the layout window, you'll see script in the onCreate method that stores the name in a persistent global variable (choose onCreate from the drop down).<br><br>Now, select the second grid and look at its onCreate script. It checks the value for "Diane" and hides the grid if this condition is met.<br><br>Let me know if you were wanting something else.
anshul9824
<p>Hi,</p>
<p> </p>
<p>Thanks for the in-depth information.</p>
<p>I was struggling in using the variable to hide the grid, as i was always writing the script in "before render" or "on render" and hence was always unsuccessful. And thing was that to write the script in the "oncreate" event of the grid to be hidden.</p>
<p>That was nicely explained and it helps me.
</p>
<p> </p>
<p>Thank you</p>
mwilliams
onRender would also work and would be needed if you're wanting to do something in a grid above where you set your variable. In this case, you'd also have to be sure to use separate run and render tasks.<br><br>Glad to help. Let us know whenever you have questions.