Date Posted:
Product: TIBCO Spotfire®
Product: TIBCO Spotfire®
Problem:
Error: 'System.MissingMemberException: NoneType object has no attribute ...' when trying to access Active Data Table or Marking using IronPython script.
Solution:
If there is a requirement to access a Data Table or Marking that belongs to an active visualization or is active then write a sample script like the one below:
dataTable = Document.ActiveDataTableReferencemarking = Document.ActiveMarkingSelectionReference
The above code may return a NULL object. One of the possible reason is that Text Area is active and since the Text Area does not have a data table, it assigns the active data table to Null. This results in the error:
'System.MissingMemberException: 'NoneType' object has no attribute ....
It is recommended to use a specified marking/table rather than using active unless there is a good reason for wanting the active table. You may use the DefaultTable/Marking or the marking /table used for a specific visualization. You can use the variable as used in the code shown below where "visual" is a script parameter of the type Visualization:
vc = visual.As[VisualContent]()
dataTable = vc.Data.DataTableReference
marking = vc.Data.MarkingReference
The above will not return Null. You can then use these objects for performing various operations:
Example:
marking.SetSelection(RowSelection(rowsToMark), dataTable)Instead of:
Document.ActiveMarkingSelectionReference.SetSelection(RowSelection(rowsToMark), dataTable)Disclaimer:
The script code in this article is only a sample to be used as a reference. It is not intended to be used "As Is" in a Production environment.
Always test in a Development environment.Make modifications to the script per your implementation specifications that suit best your business requirements. Refer to the API reference(s) cited in this article for usage of the classes and methods used in the script.
Comments
0 comments
Article is closed for comments.