Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Get first record of a dataset.
SmokesMom
I have a report where I want to set the sub title on the Master page to a value from a field in the first row of a dataset. Is there some way in one of the many scripting locations where I can get the dataset and then the first row of the dataset and set a variable based upon that value? Something like... reportContext.getDataSet.getRow(0).getValue("column_Name").
In addition, does anybody know where there is documentation for advanced scripting? I've tried reading the ROM's, but to me they are kind of useless and non-intuitive. I'm a visual person and need examples. Where I have found examples, I have been able to use them, but there is a lot out there that I'm sure I can use, but I can't figure out how without an example.
Thanks in advance for your help.
Kris
Find more posts tagged with
Comments
mwilliams
Hi Kris,
One thing you could do would be to create a variable in your initialize script with a value of 0, like:
grabFirstRecord = 0;
Then, create a new report variable, say named FirstRecord.
In your onFetch script of your dataSet, you could set the report variable's value to the first value of the dataSet with script like:
if (grabFirstRecord == 0){
grabFirstRecord = 1; //change gFR's value so that you don't reassign after first row.
vars["FirstRecord"] = row["fieldName"];
}
Let me know if you have questions.
SmokesMom
Hey Michael,
That worked great. Thanks for the quick reply. One more question. Now, if I wanted to change the sub title to a new value, where would I do that. Let me explain...
I am retrieving multiple rows from the database and grouping them by a promotional code. Each promotional code is counted for the number of rows - which works great. Each promotional code starts a new page. I need to change the subtitle on the master page to display the new promotional code. I kind of had it working with reportContext.setPersistentGlobalVariable, but I couldn't find where to get that first value. Now that I have that working (changed it to reportContext.setGlobalVariable) I am trying to get the additional pages to show the correct subtitle. I've tried changing it in onPageBreak, but that didn't work. I know it is probably something simple that I'm doing wrong, but I'll be darned if I can figure it out.
Thanks again for your time,
Kris
mwilliams
Kris,
Currently master pages do not update on page break. They are rendered once and repeated except for the autoText values from the palette while viewing the master page. If you're using 2.5.x, you may try using the variable autoText to display the field value you're wanting.
SmokesMom
Ok, thanks for your help Michael. I could have sworn that in version 2.1 this worked (with the exception of the first page). Then in version 2.3, it didn't work anymore.
Thanks again for all your help.
Kris
mwilliams
Kris,
It is possible that there was a change like that along the line somewhere. If you can use a group header or something to display this information in, those obviously update at the beginning of each group.
Jansi
<p>In my Report I need to pass One Data Set value to the Other and without using Cascading parameters or Join Data set how can i achieve this?</p>