Hello So I am working with Kentico 10.
Here is the code I am using:
string customTableClassName = "customtable.activity_variants";
CustomTableItem item = CustomTableItemProvider.GetItems(customTableClassName).WhereEquals("ActivityVariant", allActs).TopN(1).FirstOrDefault();
string productCode = ValidationHelper.GetString(item.GetStringValue("ProductCode", ""), "")
So For some context I am taking in a comma delmited list of values and splitting them then iterating through the list to look up the activity data in the cutom table by the "Activity Variant" Name so that is what allActs contains. Then I am looking my custom field of ProductCode which does exist in the custom table config as well as in the database. But when I run this I get an error saying there is a null reference. Like ProductCode doesn't exist in the table.
Here is the error I'm getting:
Message: Object reference not set to an instance of an object.
Exception type: System.NullReferenceException
and it happens on the line that I am calling the custom field.
If this looks correct then Is there a way to determine if the item has come back without check for null, I didn't see a result code or any kind of way other than calling custom fields to determine if the custom table item was returned sucessfully.