I want to run an IronPython Code automatically whenever the Spotfire Dashboard is loaded . I have come across some blogs but they are not very detailed as i am a newbee to Spotfire.
-
1great! ok so first question: is your audience viewing the analysis in the thick client (desktop version) or through the web player (browser version)? if the latter, are they accessing directly through the web player library (e.g., going to http://SpotfireServer/SpotfireWeb/ and browsing) or are you embedding the analysis/sharing links to them? – niko May 24 '16 at 17:25
-
Well Actually we are trying to build a security solution so we want to load some security tables which would bring information from Windows AD and some security mapping table. we want our dashboard to load these tables evrtime a user load these dashboards. so it will befor desktop and webplayer both. – Drake Jun 01 '16 at 21:47
2 Answers
This method is clunky, and I would prefer a better solution, if anyone has one.
I do this with a JScript (which you can find and add on the Edit HTML portion of a text area) and a Button (which I hide so nobody can see or click it).
JScript:
$(function () {
function executeScript() {
$('#hiddenBtn input').click();
}
$(document).ready(function(){executeScript()});
});
HTML:
<Span style="display:none" id="hiddenBtn">
<SpotfireControl id="f8322a6109af43fb935ad6e7bcb1f1fc" /></span>
IronPython script on HiddenButton:
if Document.Properties["OpenedYet"] == False:
Document.Properties["OpenedYet"] = True
## Script you are trying to run on open here
I don't like this method mainly because of how annoying it is for the developer. Every time you want to save the analytic, you need to go into document properties and switch the Property value of OpenedYet (which I have as a Boolean) from True to False and then you can't click anything else before you hit the save button. It also has a limitation that requires you to have a text area on the first page, which does require at least some real estate.
This may also be problematic for you, since you have desktop users; if any of them has permission to save the analytic, they may save it with the OpenedYet property set to True, so it won't run when next it opens.

- 491
- 5
- 8
Try using a flag ,so that the js executes only once.Here is an example-
$(document).ready(function()
{
if(!document.readyFlag)
{
$("#02bf0a06832f4689b1e97fd2ba9e3ec4").trigger("click");
document.readyFlag=true;
}
})

- 166
- 3