If you would like to execute the IronPython script when the cached analysis is loaded on TIBCO Spotfire Web Player, you can use the below three workarounds,
1. Using Data Functions:
Define an Input Parameter that is based on a column from a data table which is reloaded for each user. Do (Edit > Data Table Properties > select the data table > Scheduled Updates tab > Check "Reload the following data for each user" for the data table) so that there is an update when the cached report is opened by the end user which will trigger the data function execution.
For example:
Name: Update_CurrentDateTimeProperty
Script:
input
output <- Sys.time()
Input Parameter:
- Name: input
- Type: value
- Input: Expression: First([myDataTable].[myColumn])
Output parameter:
- Name: output
- Type: Value
- Output: Document property:CurrentDateTimeProperty
However if you select an table which takes time to reload then it may be time consuming. For this you may want to add a small data table and reload it for each user.
See
KB 000020939 How to execute an IronPython script on initial load of an analysis using Data Functions for more details
2. Using HTML and JavaScript:
In this approach, you need to have action control button in a Text Area visualization and associate the IronPython script to it. In the HTML you can hide this button if needed and add a JavaScript as below which will be triggerred every time the analysis is loaded and executes a button click. Sample HTML and JavaScript would be as below,
HTML:
<Span style="display:initial" id="myBtn">
<P><SpotfireControl id="0bd86d67c6414b15a9cb54aa3d7dff62" /></P>
</span>
The id here will correspond to the Button Action control
JavaScript:
$(document).ready(function()
{
if(!document.readyFlag)
{
$("#myBtn .sf-element ").trigger("click");
document.readyFlag=true;
}
})
Here readyFlag is a runtime flag used to click the button.Once the button is clicked the readyFlag is set to true, so the java script would not be re-executed.
Note:
Attached is the "ScheduledAnalysis_OnLoad.dxp" along with csv format data showing both the approaches
3. Custom DateTime Data Function for TIBCO Spotfire:
The main goal of the Custom DateTime Data Function for TIBCO Spotfire® is to enable the running of IronPython scripts on Analysis Open, Filter and Marking changes. The Custom DataTime Data Function allows one to trigger IronPython scripts without having to use a TERR/statistical Data Function for only that purpose.