Knowledge Base Article

> Knowledge Base > Rapise

Created By  inflectra.adam Wednesday, May 23, 2018

When you try and do a substring on a value returned from a database, you may get an error about the object not supporting the property.

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 = new String(Database.GetValue('CustomerId'));
var textID = text.substring((text.lastIndexOf('0')+1));


Article Info
  • Last Updated: 5/23/2018
  • Article ID: KB344
  • Views: 312