Can I use runScript() in Reporting parameter default?

  • The expression works correctly when I use it in an expression binding on a Perspective custom property. The dataset is returned.
  • When I try it in the report parameters as shown above I get,
    WARN: Error parsing default value expression for parameter "reportColors" -- Error executing script for runScript() expression:Report_Functions.reportColors

I can't find any documentation to say that runScript() won't work here.

Any ideas?

Does Report_Functions exist in your gateway scripting project?

Should not matter. Reports are part of a project, and that project's library is in scope.

Sounds like a bug.

As a workaround, use a script data source to make the call and assignment.

I don't see any reason why this shouldn't work, from a glance at the code. Should be using a project specific script manager, as you'd expect. Indeed sounds like a bug :person_shrugging:

I opened a support ticket and was then offline for a few hours. I came back to it, created a new minimalist project, go that working. I compared with the original project and it seemed the same. I must have changed something as it's working now. I've closed the ticket.

For anyone interested in having master styles for all their reports:
In Project Library I created Report_Functions with this code:

def reportColors():
	# Generate a list of standard colors for the reports.
	# Generating a dataset allows all the colors to be passed through in one parameter.
	headers = ['name', 'color']
	data = []
	data.append(["colorHeadingBg", 		"#002288"])
	data.append(["colorHeadingText",	"#FFFFFF"])
	data.append(["colorTableHeadBg",	"#777777"])
	
	return system.dataset.toDataSet(headers, data)

In the report, retrieve the reportColors dataset:


runScript("Report_Functions.reportColors")

Then extract each of the colors as follows:

  • colorHeadingBg: toColor({reportColors}[0, 1])
  • colorHeadingText: toColor({reportColors}[1, 1])
  • colorTableHeadBg: toColor({reportColors}[2, 1])

Finally, use them by adding Dynamic Data Key in the component's properties.

Unfortunately the Design tab doesn't reflect the changes but the Preview tab does.

Thanks, all.