简体   繁体   中英

How to run an IronPython Script on Spotfire Dashboard load

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.

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.

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;
}
})

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM