Reports and Datasets

I am creating a report that is going to use a dataset for a multipage table.

I want the user to click a button on the page with a report viewer to have the client run a script that creates the dataset then runs the report. (I may have multiple values for the same cells in the dataset and I want the script to figure out which value to use.)

So I think the best way is to have a dataset tag that gets populated with all my values. The script should assume that its possible for the tag data to have any number of rows and for the previous column names to have changed. (The best way to beat Murphy’s Law is to assume it.)

I see three ways to do this.

  1. Remove the Tag, Recreate the Tag empty, and fill the Tag.
  2. Clear all the rows with system.dataset.deleteRows() and test that the headers match what should be there with system.dataset.getColumnHeaders(dataset).
  3. Create a new dataset altogether using system.dataset.addColumn() and a literal dataset that is blank.

However, I see problems with all three of those.
For 1) I think removing the tag and adding it again could create a lot of extra pointers and stuff behind the scenes in the Tag Provider that doesn’t all get deleted. I could be wrong about that, I just don’t know.
For 2), the script will not always know how many rows there are, and I couldn’t find a function that would tell me. (I tried len() but got an error, that dataset doesn’t have a len attribute or something.)
3 is probably the simplest solution but I don’t know how to create a literal dataset.
(What I mean by literal dataset is like a blank literal string (ie “”) or a blank literal list (ie []))

Anyone have any ideas or comments?

For 3) I tried using None (python’s null value) but I got a large error message.

For 2), I think I can use

dataset = system.tag.getTagValue("Global/Reporting Tags/Running Report/Report Data") rows = len(system.dataset.toPyDataSet(dataset)) dataset = system.dataset.deleteRows(dataset, range(rows)) heads = system.dataset.getColumnHeaders(dataset)

Then I will compare heads against a python literal list and alert the user to a problem with a pop up if there is one.

I don't use the reporting tools at all but I see a fundamental problem with your execution of this plan.

Creating a blank or empty dataset is unnecessary. Just gather your data and use system.dataset.toDataSet() to create the new dataset. It won't matter if the columns change names or types.

Good point. I think that will work better than what I was going to try. Thanks!