As a transitional step, this site will temporarily be made Read-Only from July 8th until the new community launch. During this time, you can still search and read articles and discussions.

While the community is read-only, if you have questions or issues requiring TIBCO review/response, please access the new TIBCO Community and select "Ask A Question."

You will need to register or log in or register to engage in the new community.

How to retrieve data marking selection using IronPython in TIBCO Spotfire®

Last updated:
12:07am May 10, 2017
Back to main IronPython scripting page

Introduction

There is more than one way to retrieve marking selection, depending on the values to be retrieved. The following example shows how to retrieve values from only one column, using the DataValueCursor class.

Code sample

# Copyright © 2017. TIBCO Software Inc.  Licensed under TIBCO BSD-style license.

from System.Collections.Generic import List
from Spotfire.Dxp.Data import *

# Create a cursor for the table column to get the values from.
# Add a reference to the data table in the script.
dataTable = Document.Data.Tables["tableName"]
cursor = DataValueCursor.CreateFormatted(dataTable.Columns["yourColumnName"])

# Retrieve the marking selection
markings = Document.ActiveMarkingSelectionReference.GetSelection(dataTable)

# Create a List object to store the retrieved data marking selection
markedata = List [str]();

# Iterate through the data table rows to retrieve the marked rows
for row in dataTable.GetRows(markings.AsIndexSet(),cursor):
	#rowIndex = row.Index ##un-comment if you want to fetch the row index into some defined condition
	value = cursor.CurrentValue
	if value <> str.Empty:
		markedata.Add(value)

# Get only unique values
valData = List [str](set(markedata))

# Store in a document property
yourVariableName = ', '.join(valData)
Document.Properties["yourDocumentPropertyControl"] = yourVariableName

 

Note that you can create a cursor for each of the columns for which you intend to retrieve values.

Note that it is possible to reference the marking used in the visualization by name, instead of using Document.ActiveMarkingSelectionReference. For example, you can use:

markings = Document.Data.Markings["YourMarkingName"] 

 

References

 

License:  TIBCO BSD-Style License

Feedback (3)

Hi,

I was able to implement this script and show on a text area what is marked but I don't know how to automate the script to update the label every time something is marked. I created a button to call the script but ideally, it should be automatically. Can you provide some help?

 

Thanks.

vcavalanti 5:37pm Sep. 23, 2020
Don Johnson 12:17pm Oct. 09, 2017

Is thre any better way to store these marked rows in Tags/List ? Document property may not work when you have larege numbers of rows marked.

 

satish_thorat 8:10am Oct. 09, 2017