I am new to ironPython Scripting and I am trying the do the following.
I page in Spotfire and I created a document property input field and a listbox filter
All I am trying to do is, based on the table name given in get the listbox filter to unque values of a column of the selected table.
from Spotfire.Dxp.Application.Filters import ListBoxFilter
# Get the input variable select_table (assuming it's a Document Property)
select_table = Document.Properties["select_table"]
# Get the ListBox filter named "ReFC.WellList"
well_list_filter = None
for filter in Document.FilteringSchemes:
if filter.Title == "ReFC.WellList" and isinstance(filter, ListBoxFilter):
well_list_filter = filter
break
# Check if the ListBox filter was found
if well_list_filter is not None:
# Clear existing values from the ListBox filter
well_list_filter.Reset()
# Determine which table to use based on the selection
if select_table == "A":
table = Document.Data.Tables["Table A"]
column_name = "Well" # Assuming the column name in Table A is "Well"
elif select_table == "B":
table = Document.Data.Tables["Table B"]
column_name = "Well" # Assuming the column name in Table B is "Well"
else:
print("Invalid selection")
# Get unique values from the selected table column
unique_values = set(row[column_name] for row in table.GetRows())
# Add the unique values to the ListBox filter
well_list_filter.SetSelection(unique_values)
# Optionally, select all values in the ListBox filter
well_list_filter.IncludeAllValues = True
else:
print("ListBox filter 'ReFC.WellList' not found")
it doesnt seem to be working.. Any idea where I am going wrong?