TIBCO IronPython Scripting and Automation 2 — Questions and Answers
Question 1: How do you add a script to a Spotfire button control so it runs on click?
- Embed the script in the button's tooltip property
- In the button's Action property, link a Script action referencing the IronPython script (Correct answer)
- Write a JavaScript onclick handler on the button
- Configure the button in the server's automation service
Correct answer: In the button's Action property, link a Script action referencing the IronPython script
Spotfire button controls have an Action property where you attach a 'Script action' that references an IronPython script stored in the analysis.
Question 2: In Spotfire IronPython, what does 'Document.Properties' provide access to?
- Server-side document metadata only
- Custom document properties that act as analysis-level variables readable/writable by scripts (Correct answer)
- Read-only analysis title and author fields
- File system properties of the .dxp file
Correct answer: Custom document properties that act as analysis-level variables readable/writable by scripts
Document properties are custom key-value pairs defined in the analysis that scripts can read and modify to pass data between actions.
Question 3: Which IronPython approach is used to change the active page in a Spotfire analysis programmatically?
- Document.Pages.SetActive(pageIndex)
- Document.ActivePageReference = Document.Pages[pageIndex] (Correct answer)
- Application.NavigateTo(pageIndex)
- Document.CurrentPage = pageIndex
Correct answer: Document.ActivePageReference = Document.Pages[pageIndex]
Setting Document.ActivePageReference to a page object from Document.Pages switches the visible page.
Question 4: In Spotfire IronPython, what is the correct way to add a calculated column to a data table?
- table.AddCalculatedColumn(name, expression)
- table.Columns.AddCalculatedColumn(name, expression) (Correct answer)
- DataColumn.Create(table, name, expression)
- table.Columns.Add(name, 'Calculated', expression)
Correct answer: table.Columns.AddCalculatedColumn(name, expression)
DataTable.Columns.AddCalculatedColumn(name, expression) adds a new calculated column with the given expression to the specified table.
Question 5: What is the purpose of 'Script parameters' in Spotfire IronPython scripts?
- Command-line arguments passed when launching Spotfire
- Named inputs defined on the script that link to document properties, visualizations, or data tables at runtime (Correct answer)
- Environment variables read from the server
- Spotfire API authentication tokens
Correct answer: Named inputs defined on the script that link to document properties, visualizations, or data tables at runtime
Script parameters are declared inputs that bind the script to document properties, data tables, or filtered rows, passing runtime context to the script.
Question 6: In Spotfire IronPython, which class is used to programmatically set a list box filter's selected values?
- ListBoxFilter (Correct answer)
- CheckBoxFilter
- RangeFilter
- FilterValue
Correct answer: ListBoxFilter
ListBoxFilter is the Spotfire filter class for list/categorical selections and provides methods to set which items are checked.
How do you add a script to a Spotfire button control so it runs on click?