How to control warning in Servoy 6

Hi all,

I’ve this kind of code:

var _myFoundset = databaseManager.getFoundSet("my_repository","my_table");
      _myFoundset.my_field = "hello"

and I obtain a warning like “the property ‘my_field’ is undefined for the type JSFoundset”.

I wouldn’t this kind of warning: the only way is to disable it from the preference?
or does exist a way to write it to avoid this warning? (I wantn’t use a design form foundset)

Thanks for the help

Marco

Hi Marco,

When you use the databaseManager.getFoundSet() function you get an empty foundset so you first need to load any record(s) or create them in this foundset.

Hope this helps.

Marco R.:
or does exist a way to write it to avoid this warning?

You can use jsdoc to let Servoy know what kind of foundset is in the variable:

/** @type {JSFoundset<db:/my_repository/my_table>} */
var _myFoundset = databaseManager.getFoundSet("my_repository","my_table");
_myFoundset.my_field = "hello"

Then the warnings will disappear.

Ok!

Thank you all for your answers.
It will be usefull.

Ok, one last thing:

I’ve a MEDIA variable called “root”.

At the startup a global fuction will instantiate “root” as Object()

globals.root = new Object()

I use it as an Object array by:

globals.root[_myCurrCollection] = new Object()

and fill its variables:

globals.root[_myCurrCollection].myLength = 0;
globals.root[_myCurrCollection].myWidth = 100;
globals.root[_myCurrCollection].myCandies = 200;
globals.root[_myCurrCollection].myList = new Array()
etc..

At now it’s all ok but when I point to “globals.root[_myCurrCollection].myLength” by a form-function, I obtain a warning as “undefined in javascript”.

I’ve tried to use:

/** @type {Number}  */

over the variable initialization but I suppose that it works just into the instance case.

What is the right way to solve this?

Thanks in advance.

Marco

look here:
http://wiki.servoy.com/display/public/D … sing+JSDoc

under the section Object Type and so on

in your example globals.root looks a lot like:

Object<{{myLength :Number, myWidth :Number,myCandies :Number, myList :Array}}>

Thanks Johan!

I’ll use it for any future necessity!

I’ve tried to follow what you have suggested and I’ve put for example:

As global:

/** @type {Object<{{MyName:String}}>}*/
var root = new Object()

but when I save the changes it becames:

/** @type {Object< MyName:String >} */

with warning “Unknow type MyName.”

Into the wiki I’ve found:

{ {name:String, age:Number}} 

so I’ve tried to put

/** @type {{MyName:String}} */

but after saving I obtain

/** @type {MyName:String} */

with warning “Unknow type MyName”.

Am I missing to do something?

Thanks

no you dont miss anything thats currently a bug in 6.0.1 (the removal of the { } )
Is already fixed for 6.0.2

Ok thanks, I’ll wait for it!