property length is undefined in javascript?

Questions, tips and tricks and techniques for scripting in Servoy

property length is undefined in javascript?

Postby juan.cristobo » Thu May 17, 2012 5:43 pm

Hi, I have this code:

Code: Select all
  * @type {JSDataSet}
var dataset = databaseManager.getDataSetByQuery(...);

if(dataset.getValue(1,5).length < 6) {

I receive this warning:

Code: Select all
property length is undefined in javascript

How can I do to set the type of dataset.getValue(1,5) (it's a string value)?

Madrid (Spain)

Servoy 7.4.x - MySQL / SQL Server 2008-2016
Windows 10 Pro
Posts: 186
Joined: Thu Apr 19, 2012 9:12 am

Re: property length is undefined in javascript?

Postby goldcougar » Fri May 18, 2012 1:09 am

Well, the value could be null, so you should check it first, like:

Code: Select all
if(dataset.getValue(1,5) && dataset.getValue(1,5).length < 6) {

If your curious to see what the type is, use:

Code: Select all
application.output(typeof dataset.getValue(1,5))
Scott Butler
iTech Professionals, Inc.
SAN Partner

Servoy Consulting & Development
Servoy University- Training Videos
Servoy Components- Plugins, Beans, and Web Components
Servoy Guy- Tips & Resources
ServoyForge- Open Source Components
User avatar
Servoy Expert
Posts: 688
Joined: Sun Jan 08, 2006 7:15 am
Location: Cincinnati, OH

Return to Methods

Who is online

Users browsing this forum: No registered users and 3 guests