Jump to content

html data entry form within Spotfire


Malek Mansour 2

Recommended Posts

I need to display data record in a single record format instead of tabular. Data will be loaded using information link and would need to be able to update selected fields and writ back to database. Currently I created a text area with input fields as place holder with a submit script to update selected record with values from the text area input field. Is this the best way to do that

Best,

Link to comment
Share on other sites

  • 2 weeks later...

Hello Mlk,

 

There is no out of the box functionality to write back to the database and thus there is no best solution.  However many users have been able to create their own solutions for this by using a mixture of scripts and stored procedures.

 

One approach is to use Information Links to write back to the database, but also combining the procedures and scripting with this. You create a stored procedure in the database that has all the logic and does the writing to the database. You then add this to the Information Link, and create a script that passes the wanted parameters to this Information Link & procedure. Then executes this information link, so that the parameters gets written to the database.

 

Here's an example of how to work with an Information Link Data Source using IronPython script. You'll have to modify it to fit your own scenario however, but I hope it helps:

 

from System import Array,Guid,String,Object
from Spotfire.Dxp.Data.Import import InformationLinkDataSource, InformationLinkParameter
from Spotfire.Dxp.Data import *

#Function to return a Spotfire Data Table. Will return None if the data table does not exist
#parameter: tableName - the name of the data table in the Spotfire document
def getDataTable(tableName):
try:
	return Document.Data.Tables[tableName]
except:
	print ("Cannot find data table: " + tableName + ". Returning None")
	return None

#The GUID of the information link to be executed (Right-click, Copy ID from the information designer)
ilGuid = "06353b96-943e-450a-905b-5a623c38cbe1"

#Build the Information Link parameters and set their values
ilParameters = []
ilParameter = InformationLinkParameter.CreateNamedParameter("Parameter1",Array[Object]([param1Value]))
ilParameters.append(ilParameter)
ilParameter = InformationLinkParameter.CreateNamedParameter("Parameter2",Array[Object]([param2Value]))
ilParameters.append(ilParameter)

#Create the Information Link Data Source and assign the parameters
ilDataSource = InformationLinkDataSource(Guid(ilGuid))
ilDataSource.Parameters = ilParameters

#Add/Refresh the data table, which will execute the Information Link
dt = getDataTable(actionsDtName)
if dt != None:
dt.ReplaceData(ilDataSource)
else:
Document.Data.Tables.Add(actionsDtName, ilDataSource)

====

 

Please also review the below article

 

http://spotfired.blogspot.com/2014/04/write-back-to-database-from-spotfire.html

Link to comment
Share on other sites

  • 1 year later...
I've created an html form in tibco spotfire text area. I've created property controls with 3 parameters, (2 strings and 1 integer). I've created a submit button. The problem I have at the moment is that I need a spotfire script to collect the data from the html forms(the property controls), and submit the data back into the information link I've created, to write back to the data table, once the submit form button is clicked. How do I do this Does anyone have a script that does this sort of thing
Link to comment
Share on other sites

There is no out of the box functionality to write back to the database and thus there is no best solution.However many users have been able to create their own solutions for this by using a mixture of scripts and stored procedures.

One approach is to use Information Links to write back to the database, but also combining the procedures and scripting with this. You create a stored procedure in the database that has all the logic and does the writing to the database. You then add this to the Information Link, and create a script that passes the wanted parameters to this Information Link & procedure. Then executes this information link, so that the parameters gets written to the database.

Here's an example of how to work with an Information Link Data Source using IronPython script. You'll have to modify it to fit your own scenario however, but I hope it helps:

from System import Array,Guid,String,Object

from Spotfire.Dxp.Data.Import import InformationLinkDataSource, InformationLinkParameter

from Spotfire.Dxp.Data import *

 

#Function to return a Spotfire Data Table. Will return None if the data table does not exist

#parameter: tableName - the name of the data table in the Spotfire document

def getDataTable(tableName):

try:

return Document.Data.Tables[tableName]

except:

print ("Cannot find data table: " + tableName + ". Returning None")

return None

 

#The GUID of the information link to be executed (Right-click, Copy ID from the information designer)

ilGuid = "06353b96-943e-450a-905b-5a623c38cbe1"

 

#Build the Information Link parameters and set their values

ilParameters = []

ilParameter = InformationLinkParameter.CreateNamedParameter("Parameter1",Array[Object]([param1Value]))

ilParameters.append(ilParameter)

ilParameter = InformationLinkParameter.CreateNamedParameter("Parameter2",Array[Object]([param2Value]))

ilParameters.append(ilParameter)

 

#Create the Information Link Data Source and assign the parameters

ilDataSource = InformationLinkDataSource(Guid(ilGuid))

ilDataSource.Parameters = ilParameters

 

#Add/Refresh the data table, which will execute the Information Link

dt = getDataTable(actionsDtName)

if dt != None:

dt.ReplaceData(ilDataSource)

else:

Document.Data.Tables.Add(actionsDtName, ilDataSource)

 

====

Link to comment
Share on other sites

You can refer to the script in the following wiki article,

 

https://community.spotfire.com/wiki/how-write-back-database-tibco-spotfirer-using-ironpython-scripting

 

 

 

To retrieve the values from document properties to your script below would be the code

 

value1=Document.Properties["property1"]
value2=Document.Properties["property2"]
value3=Document.Properties["property3"]

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