Jump to content

Recommended Posts

Posted

Hi Experts,

 

I have a script that i need to run on the first of the of the month (or on certain dates). Can you please assist on the steps to achieve this Your help is appreciated .

Thanks in advance

Posted

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...

Posted

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

Posted

Here is a working example.

You'll firstRegister Data Function.

 

the input should be a table that loads when the dxp opens

the output will be the system time

the output will go to a document property

 

#Any Table to act as input

input

#Send Timestamp to Document Property

output

Posted

Hi Tyger0951,

 

Thanks for the response. I was not able to open the dxp file due to a version conflict. I will try to rectify the script based on your response. Does this mean i dont need to add my document property in the new script you sent

Posted
You don't have to use the documents property in the python script datetime.date.today() will the same as datetime.datetime(Document.Properties['docname']) as your document property is getting a timestamp from your data function. 
Posted

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)

Posted

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 

Posted

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

 

 

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...