Using a String Database Value

If you try to do something like the following to get a database value and then do a SubString on it:

var text = Database.GetValue('CustomerId');
var textID = text.substring((text.lastIndexOf('0') + 1));

You will get an error message of the type:

Object doesn't support ........

The solution is to cast the returned value as a String:

var text = "" + Database.GetValue('CustomerId');
var textID = text.substring((text.lastIndexOf('0') + 1));