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)
Reading values from a table into an Array
motodave452
<p>Hello,</p>
<p> </p>
<p>I am in the process of designing a line graph that will graph out the amount of participants that are in a conference call at a given time. To accomplish this I am pulling data from a data base. This data consists of "Connect Times" which are times that a participant entered a call, and "Disconnect Times", which are the times that the participant left a call. I am using a Scripted Data Set to set up my graph and all is fine so far except for getting access to these "Connect" and "Disconnect" times. </p>
<p> </p>
<p>Here comes my problem:</p>
<p> </p>
<p>I have a table set up like the following:</p>
<p> </p>
<p><strong>*see attached connectTable.png</strong></p>
<p>ColumnValue9 are connect times, and ColumnValue10 are disconnect times</p>
<p> </p>
<p>I have a query set up to populate this table and when I display this table in the report engine I get the following:</p>
<p> </p>
<p><strong>*see attached dataTable.png</strong></p>
<p> </p>
<p>You can see that there are 5 connect times and 5 disconnect times that get displayed when I display my table.</p>
<p> </p>
<p>The problem that I am having is that I can only access the last connect time, and the last disconnect time. You can see that in the connectTable.png there is only one row for each, but when it is displayed in dataTable.png there are 5 (based on the number of participants in a call). It is like each time it populates, it overwrites the previous value until all I have left in ColumnValue9 is the last value. Although when it displays, it displays them all. Hopefully I am making sense.</p>
<p> </p>
<p><strong>My question is:</strong> Is there a way that I can get all of the connect times displayed in the above dataTable.png, into an array? I need to be able to place all 5 of the above connect times in an array, so that I can loop over them within my scripted data set to see if a participant was in the call or not at a given time. I am stumped at this as every way I have tried to do it I can only get access to the last value.</p>
<p> </p>
<p>I greatly appreciate any help that anyone can offer as I have been trying to accomplish this for quite some time with no luck. Thank you very much!</p>
<p> </p>
<p>Best,</p>
<p> </p>
<p>Dave</p>
Find more posts tagged with
Comments
motodave452
<p>Maybe it is worth noting that in the onCreate script for my table depicted in <strong>connectTable.png</strong>, I am getting a handle to ColumnValue9 and ColumnValue10 by doing the following:</p>
<p> </p>
<p>vars["vConnectTime"] = this.getRowData().getColumnValue("ColumnValue9");<br>
vars["vDisconnectTime"] = this.getRowData().getColumnValue("ColumnValue10");</p>
<p> </p>
<p> </p>
<p>But my problem is these variables that I have defined only hold the last value, not all 5 values that are being displayed in <strong>dataTable.png</strong></p>
Clement Wong
<p>Hi motodave452,</p>
<p> </p>
<p>One technique would be to save your values into an global variable array within the first data set with the connect and disconnect times.</p>
<p> </p>
<p>1. In the <em>beforeOpen </em>event of the dataset that has the connect and disconnect times, create an ArrayList.</p>
<pre class="_prettyXprint">
theCallArray = new java.util.ArrayList();</pre>
<p>2. In the <em>onFetch </em>event of the first data set, save the row of the start time (ColumnValue9) and the end time (ColumnValue10) into the ArrayList created in Step 1.</p>
<pre class="_prettyXprint">
var tempArray = [];
tempArray.push(row["ColumnValue9"]);
tempArray.push(row["ColumnValue10"]);
theCallArray.add(tempArray);</pre>
<p>3. In the <em>beforeClose </em>event of the first data set, save the ArrayList into a PGV or GV depending on where you want to use it next.</p>
<pre class="_prettyXprint">
reportContext.setPersistentGlobalVariable("theCallArray",theCallArray);
</pre>
<p>Finally, in your second data set, you can access this PGV and process accordingly.</p>
<pre class="_prettyXprint">
someVarName = reportContext.getPersistentGlobalVariable("theCallArray");
// Size of array: theCallArray.size()
// Element 0,0 (Caller 1, StartTime): theCallArray[0][0]
// Element 0,1 (Caller 1, EndTime): theCallArray[0][1]
</pre>
<p>
</p>
motodave452
<p>Thank you very much for your reponse. I feel like the way you did it would be a better option. Before I saw your response I actually figured out a way to do it a little bit differently.</p>
<p> </p>
<p>In the main initialize script for my report I declared the following:</p>
<pre class="_prettyXprint">
var connectArray = new Array();
var connectCount = 0;
var disconnectArray = new Array();
var disconnectCount = 0;</pre>
<p>Then in my onCreate script for my table I did the following:</p>
<pre class="_prettyXprint">
connectArray[connectCount] = this.getRowData().getColumnValue("ColumnValue9");
connectCount++;
disconnectArray[disconnectCount] = this.getRowData().getColumnValue("ColumnValue10");
disconnectCount++;</pre>
<p>Then in my Scripted Data Set in the fetch script where I am populating my table to use for my Line Graph I can access those arrays and their contents. It probably isn't the best way to do it but it seems to accomplish what I am trying to do. If I get some time I am definitely going to try your method as it seems like a better practice than the way I am doing mine.</p>
<p> </p>
<p>Again, thank you for your help!</p>
<p> </p>
<p>-Dave</p>