Date Posted:
Product: TIBCO Spotfire®
Product: TIBCO Spotfire®
Problem:
How to execute an IronPython script on Filter or Marking change.
Solution:
Out of the box, it is not possible to execute an IronPython script when Filter or Marking changes. However, we can use Data Functions and Document Properties to achieve this. Document Properties can trigger IronPython scripts when their value changes. We will leverage this feature. High level and detailed steps are described below.
High level steps:
- Create a dummy data function that runs when a filter changes.
- Associate the output value of this data function to a document property.
- Associate the IronPythonscript to this Document Property so it will be triggered when the document property changes.
Detailed steps:
- Edit >> Data Function Properties
- Click on "Register New"
- Name: triggerOnFilterChange
- Type: R Script - TIBCO Enterprise Runtime for R
- Description: Data function to pass value of x to y and current time to z
- Script: (#Here we are just passing the value of x to y, and then current time to z)
This way we ensure that the function is triggered when x, which is based on Filter, changesy <- x z <- Sys.time()
- Input Parameters >> Add >> x, Allowed Data Types: Integer
- Output Parameters >> Add >> y and z
- Run
- Edit Parameters
- Check the "Refresh Function Automatically" checkbox
- Input #Input will come from the filter/marking. Make changes in the expression as needed.
- Input Handler: Expression
- Data Table: Your data table
- Expression: Count([Your table].[Column of choice])
- Limit By: Filtering scheme #Choose marking if you want to trigger script based on Marking
- Output
- Select y
- Output Handler: Document Property
- New, DocProp1
- Select z
- Output Handler: Document Property
- New, DocProp2
- Ok
- Close #Save to Library if you wish to
- Edit >> Document Properties >> Properties
- Select DocProp2
- Script >> Execute the script selected below
- Select the existing IronPython script, or click New to create a new IronPython script, that you would like to execute on filter/marking change, and click OK.
Comments
0 comments
Article is closed for comments.