Scripting.ScriptException

Hello,

I’m encountering difficulties when using .Net commands on a dataset to create a calculated item, more specifically the error log is:
"
Transform Name: 1st Level
Transform Type: Calculated Element
Connector Element: Derived Column Output
Element Name: Computed
Dundas.BI.Scripting.ScriptException: Runtime error Object reference not set to an instance of an object. Line: 15 Column: 10 —> System.NullReferenceException: Object reference not set to an instance of an object.
"
the computation is fairly basic:
"
String name = $field_name$;
if ( name.Contains(“string”)) {return “new string”}
else {return name}
"
I’ve tried inserting a null replacement transform but I get an " ExecuteReader: CommandText property has not been initialized" error (I don’t have admin privileges

Thank you

A null reference exception is probably coming from the name.Contains… portion as if you have a field name of null, you will see that error thrown. What you’ll want to do is to check for nulls to avoid that error and then handle nulls separately. Something like this:

String name = $field_name$;
if (name != null) {
    // your code above
} else {
    // handle a null case... likely just returning the name
}
1 Like