Jump to content

IronPython Script to run once a month


Anthony stark

Recommended Posts

There isn't any straightforward approach for this. However below as a workaround may help:

You can use Automation Services for the same which in turn can be scheduled at will.

As such it is possible to update a document property from Automation service using configuration block. Below is how the Job XML would look like.

 

 

 

 

Open Analysis from Library

/Introduction to Spotfire

MyProperty="HelloWorld";

 

 

 

You may check documentation on configuration block in Automation Service here:

https://docs.tibco.com/pub/spotfire_server/latest/doc/html/TIB_sfire_aut...

 

And then you may add your python script to be executed on changing the document property value.

How to trigger script on property change:

Start by creating the property that triggers the script. Go to [Edit > Document Properties > Properties tab > New...]. Select the new script in the available properties list and click the 'Script...' button. Select 'Execute the script selected below' and select the script you want to execute.

And to schedule an Automation Services Jobs check the below link:

Scheduling the Client Job Sender

https://docs.tibco.com/pub/spotfire_server/latest/doc/html/TIB_sfire_aut...

Link to comment
Share on other sites

Use this methodhttps://support.tibco.com/s/article/Tibco-KnowledgeArticle-Article-44163

to tigger a python script on load. And in your python script take the document property (the timestamp) and check if it's the first of the month.

 

import datetime

 

todayDate = datetime.datetime(Document.Properties['OnloadTimeStamp'])

if todayDate.day == 1:

myFunction()

else:

pass

Link to comment
Share on other sites

Hi Tyger,Im getting the following error when running that script:name 'myfunction' is not defined

   at IronPython.Runtime.PythonContext.MissingName(SymbolId name)

   at Microsoft.Scripting.Runtime.LanguageContext.LookupName(CodeContext context, SymbolId name)

   at Microsoft.Scripting.Runtime.RuntimeHelpers.LookupName(CodeContext context, SymbolId name)

Link to comment
Share on other sites

Hi Tyger,This is the whole script: import datetime

todayDate = datetime.date.today()

if todayDate.day == 12:

    from Spotfire.Dxp.Data import AddRowsSettings

from Spotfire.Dxp.Data.Import import DataTableDataSource#Source Data Table

sourceDataTable=Document.Data.Tables["Repo"]

dataSource=DataTableDataSource(Document.Data.Tables["Repo"])#Append rows to new data table

destinationDataTable=Document.Data.Tables["APPENDED"]

rowsettings=AddRowsSettings(destinationDataTable,dataSource)

destinationDataTable.AddRows(dataSource,rowsettings)

sourceDataTable.Refresh()else:

    passwhen i run it this way it i get this error: File "", line 19

    else:    ^

SyntaxError: unexpected token 'else'Any idea what the issue might be 

Link to comment
Share on other sites

Python is indent sensitive : 

 

 

 

This would be the proper format for the script: 

 

from Spotfire.Dxp.Data import AddRowsSettings
from Spotfire.Dxp.Data.Import import DataTableDataSource
import datetime

todayDate = datetime.date.today()
if todayDate.day == 12:
#Source Data Table
sourceDataTable=Document.Data.Tables["Repo"]
dataSource=DataTableDataSource(Document.Data.Tables["Repo"])
#Append rows to new data table
destinationDataTable=Document.Data.Tables["APPENDED"]
rowsettings=AddRowsSettings(destinationDataTable,dataSource)
destinationDataTable.AddRows(dataSource,rowsettings)
sourceDataTable.Refresh()
else:
   pass

 

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...