Jump to content

How to use data column as variable in a script


Bernhard Fleischmann

Recommended Posts

Hi,

this might be an easy one for experienced users. I want to use a small script to link to a URL from an icon in a graphical table.

I am creating the URL using Concatenate in a calculated column. How can I pull it into the script to replace the URL part in the example below

import System

System.Diagnostics.Process.Start("http://www.tibco.com");

Thanks in advance,

Bernhard

Link to comment
Share on other sites

Hi Bernhard,

When clicking on a graphical table icon, this marks the data - from that, you can get the value of your calculated column and then open that URL.

Something like this:

# Copyright 2021. TIBCO Software Inc.

# License: https://community.spotfire.com/wiki/tibco-bsd-style-license

# Author: Andrew Berridge, TIBCO Software, February 2022

 

# Open a URL from a calculated column - used as an action in a graphical table

# Parameters - graphicalTable - the graphical table must be supplied

 

 

from System import Array,Guid,String,Object

import System

from Spotfire.Dxp.Data import *

from Spotfire.Dxp.Application.Visuals import VisualContent

 

vis = graphicalTable.As[VisualContent]()

dataTable = vis.Data.DataTableReference

marking = vis.Data.MarkingReference

 

cursor = DataValueCursor.CreateFormatted(dataTable.Columns["Url"])

 

for row in dataTable.GetRows(marking.GetSelection(dataTable).AsIndexSet(), cursor):

url = cursor.CurrentValue

print url

System.Diagnostics.Process.Start(url);

 

# unmark marked rows:

marking.SetSelection(RowSelection(IndexSet(dataTable.RowCount, False)), dataTable)I hope that helps!

Andrew Berridge (TIBCO Data Science)

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