Anthony stark Posted March 5, 2020 Posted March 5, 2020 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
Rayees Wani Posted March 6, 2020 Posted March 6, 2020 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...
Tyger Guzman 2 Posted March 6, 2020 Posted March 6, 2020 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
Anthony stark Posted March 6, 2020 Author Posted March 6, 2020 @tyger0951, the steps are kind of confusing, when do i enter the script you put above
Anthony stark Posted March 6, 2020 Author Posted March 6, 2020 Hi Rayees,is the document property going to be a column in the Data table How will it know when the first of the month is
Anthony stark Posted March 10, 2020 Author Posted March 10, 2020 @tyger0951 The code above gives the following error: SyntaxError: unexpected token '='
Tyger Guzman 2 Posted March 10, 2020 Posted March 10, 2020 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
Anthony stark Posted March 10, 2020 Author Posted March 10, 2020 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
Tyger Guzman 2 Posted March 10, 2020 Posted March 10, 2020 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.
Anthony stark Posted March 12, 2020 Author Posted March 12, 2020 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)
Tyger Guzman 2 Posted March 12, 2020 Posted March 12, 2020 Replace myfunction() with python script (whatever your original code was) myfunction () is just an example
Anthony stark Posted March 12, 2020 Author Posted March 12, 2020 Hi Tyger.-Thanks for the response Do i put the whole code in the bracket Can you give an example of how the sytax will look
Anthony stark Posted March 12, 2020 Author Posted March 12, 2020 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
Tyger Guzman 2 Posted March 12, 2020 Posted March 12, 2020 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
Anthony stark Posted March 12, 2020 Author Posted March 12, 2020 Thanks tyger0951, I appreciate the effort you put into this
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now