Closed nikomaresco-csg closed 2 months ago
You are correct, the indexed property on a DataColumnCollection throws if a column with the name is missing. The proper way to write the function would be to use the TryGetValue API.
I have updated the snippet so it works as expected, thanks for pointing this out!
on the Snippets page, the example "Insert columns to an existing data table with custom column match" has a function
getColumnOrThrow()
, below:https://spotfiresoftware.github.io/spotfire-mods/docs/action-mods/snippets/#insert-columns-to-an-existing-data-table-with-custom-column-match
but this null check is never executed, because if the column does not exist, the API throws the following error, halting the script:
to capture the error and maybe add more info, you could use:
however in this example you're forced to use the
!
operator, which might not be desired.are there any other scenarios in which
table.Columns.Item.get(columnName)
can return a null value?