This script is to enable an IronPython script to trigger and run after a filter or marking has been changed.

Register new data function

To enable the trigger, you'll first need to create a data function using the Spotfire TERR.

Go to Tools in the menu and select "Register Data Function"

Input the following details:

  • Name it "triggerOnFilterChange"
  • Select "R script - TIBCO Enterprise Runtime for R"
  • Description: Data function to pass value of x to y and current time to z
  • Script:
Spotfire R
y <- x
z <- Sys.time()

Navigate to the "Input Parameters" tab, click "Add"

Input the parameter name as "x" and the type as "integer", click "OK".

Navigate to the "Output Parameters" and click "Add"

Input the parameter name as "y" and click "OK"

Do the same for "z" and click "OK"

Click "Run" on the top of the window

The next screen that pops up will be the settings

Ensure that "Refresh Function automatically" is enabled
Expression is selected
The data table is primary data table
Limit by the applicable filtering scheme and/or marking

Click "Edit" on the expression

Input just a simple count calculation expression, it can be on any column, it just needs to be able to pass a row count through the function. Click "OK"

Navigate to the "Output" tab, select "y", select "Document property" and click "New"

Name the new document property "OnChangeY"

Do the same for Z, until the screen looks similar to below:

Click "OK"

Click "Close"

When the prompt appears, click "No"

Assigning a script to run on the document property

Now that the Spotfire R script updates a document property on filter change, it is then that you can assign a script to run on the document property.

Go to "Document properties" and select "Properties", select "OnChangeY" and click "Script"

Select "Execute the script selected below" and select your script

All done, when a filter changes, the document property will be updated, which will then trigger your IronPython script. Enjoy!

Sources

  • No labels