I am using TIBCO Spotfire Server v7.11.1and Ironpython 2.7.7
and following one of wiki toretrieve data marking selection, and I got error.
(
https://community.spotfire.com/wiki/how-retrieve-data-marking-selection-usi...
)
can anybody give some tip about this error
[script]
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["AVG"]
cursor = DataValueCursor.CreateFormatted(dataTable.Columns["lot_wf"])
# 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
#####################ERROR########################
Traceback (most recent call last):
File "", line 10, in
AttributeError: 'NoneType' object has no attribute 'GetSelection'
System.MissingMemberException: 'NoneType' object has no attribute 'GetSelection'
at Microsoft.Scripting.Interpreter.ThrowInstruction.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.LightLambda.Run3[T0,T1,T2,TRet](T0 arg0, T1 arg1, T2 arg2)
at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1)
at Microsoft.Scripting.Interpreter.DynamicInstruction`3.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.LightLambda.Run2[T0,T1,TRet](T0 arg0, T1 arg1)
at IronPython.Compiler.PythonScriptCode.RunWorker(CodeContext ctx)
at Microsoft.Scripting.Hosting.ScriptSource.Execute(ScriptScope scope)
at Spotfire.Dxp.Application.IronPython27.IronPythonScriptEngine.ExecuteForDebugging(String scriptCode, Dictionary`2 scope, Stream outputStream)
Im sorry. I did it again, it works. but I have new question.I changed this code..
markings = Document.ActiveMarkingSelectionReference.GetSelection(dataTable)
to..
markings = Document.Data.Markings["YourMarkingName"] ////// (my case : markings = Document.Data.Markings["Marking (2)"] )
(
because of this comment of wiki
: 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:)But then, this code doesnt work again like below error messege. can you check it ###################ERROR MESSEGE########################Traceback (most recent call last):
File "<string>", line 16, in <module>
AttributeError: 'DataMarkingSelection' object has no attribute 'AsIndexSet'
System.MissingMemberException: 'DataMarkingSelection' object has no attribute 'AsIndexSet'
at IronPython.Runtime.Binding.PythonGetMemberBinder.FastErrorGet`1.GetError(CallSite site, TSelfType target, CodeContext context)
at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1)
at Microsoft.Scripting.Interpreter.DynamicInstruction`3.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.LightLambda.Run2[T0,T1,TRet](T0 arg0, T1 arg1)
at IronPython.Compiler.PythonScriptCode.RunWorker(CodeContext ctx)
at Microsoft.Scripting.Hosting.ScriptSource.Execute(ScriptScope scope)
at Spotfire.Dxp.Application.IronPython27.IronPythonScriptEngine.ExecuteForDebugging(String scriptCode, Dictionary`2 scope, Stream outputStream)