# Servoy and the databaseManager.getFoundSet in Servoy 6.1

**URL:** <https://forum.servoy.com/t/servoy-and-the-databasemanager-getfoundset-in-servoy-6-1/16297>\
**Category:** Classic Servoy\
**Created:** [August 2, 2012, 5:02pm UTC](https://forum.servoy.com/t/servoy-and-the-databasemanager-getfoundset-in-servoy-6-1/16297 "2012-08-02T17:02:47Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![jcarlos](https://avatars.discourse-cdn.com/v4/letter/j/46a35a/32.png) [@jcarlos](https://forum.servoy.com/u/jcarlos)\
**Post date:** [August 2, 2012, 5:02pm UTC](https://forum.servoy.com/t/servoy-and-the-databasemanager-getfoundset-in-servoy-6-1/16297/1 "2012-08-02T17:02:47Z")

</div>

It seem that Servoy does not recognize the following:

var serverName = databaseManager.getDataSourceServerName(controller.getDataSource());  
var fs = databaseManager.getFoundSet(serverName,‘documents\_content’);

Because I get these warning:

The property document\_content is undefined for the type JSFoundSet  
The property document\_content\_id is undefined for the type JSFoundSet  
The property document\_keywords is undefined for the type JSFoundSet  
The property document\_subject is undefined for the type JSFoundSet  
The property document\_summary is undefined for the type JSFoundSet  
The property metadata\_author is undefined for the type JSFoundSet  
The property metadata\_charset is undefined for the type JSFoundSet  
The property metadata\_content\_type is undefined for the type JSFoundSet  
The property metadata\_creator is undefined for the type JSFoundSet  
The property metadata\_error\_code is undefined for the type JSFoundSet  
The property metadata\_error\_message is undefined for the type JSFoundSet  
The property metadata\_extension is undefined for the type JSFoundSet  
The property metadata\_file\_name is undefined for the type JSFoundSet  
The property metadata\_file\_path is undefined for the type JSFoundSet  
The property metadata\_filesize is undefined for the type JSFoundSet  
The property metadata\_initial\_file\_name is undefined for the type JSFoundSet  
The property metadata\_initial\_path\_or\_url is undefined for the type JSFoundSet  
The property metadata\_last\_modified is undefined for the type JSFoundSet  
The property metadata\_producer is undefined for the type JSFoundSet  
The property metadata\_title is undefined for the type JSFoundSet

The ‘properties’ are undefined for the type JSFoundSet. It seems that Servoy does not recognize the fs variable I defined above.

If I defined the found set variable through the relation, the js variable is recognized. I don’t get the warnings if I define the js variable like this: var fs = foundset.documents\_content\_ref01. But defining the fs variable in this way does not work for my method.

Is there a problem with Servoy and the databaseManager.getFoundSet or am I doing something wrong here?

BTW, this works perfectly in Servoy 5.x, and still works in Servoy 6.1, it’s just that I get the warnings.

Best,  
Carlos

The entire method with the warnings is attached (smartDocProcessCallback.pdf)

[smartDocProcessCallback.pdf](https://forum.servoy.com/uploads/short-url/wddPYqH30ZelezldJhg7PD6xvF3.pdf) (15.6 KB)

---

<div class="post-metadata">

**Author:** ![Joas](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/joas/32/5095_2.png) [@Joas](https://forum.servoy.com/u/Joas)\
**Post date:** [August 3, 2012, 8:06am UTC](https://forum.servoy.com/t/servoy-and-the-databasemanager-getfoundset-in-servoy-6-1/16297/2 "2012-08-03T08:06:42Z")

</div>

Servoy doesn’t recognize the table of this foundset, because the argument is just a string. This string can only be evaluated at runtime, so Servoy has no idea about its content.

To let Servoy know that this foundset is from the table documents\_content, you can add a bit of JSdoc:

```auto
var serverName = databaseManager.getDataSourceServerName(controller.getDataSource());

/** @type {JSFoundSet<db:/your_server_name/documents_content>} */
var fs = databaseManager.getFoundSet(serverName,'documents_content');

```

Now your warnings should disappear.  
An extra advantage of this is that you now get all the fields and relation of this table in the code completion of your fs variable.

---

<div class="post-metadata">

**Author:** ![jcarlos](https://avatars.discourse-cdn.com/v4/letter/j/46a35a/32.png) [@jcarlos](https://forum.servoy.com/u/jcarlos)\
**Post date:** [August 3, 2012, 3:10pm UTC](https://forum.servoy.com/t/servoy-and-the-databasemanager-getfoundset-in-servoy-6-1/16297/3 "2012-08-03T15:10:06Z")

</div>

Joas,

1. THANK YOU very much. This work perfectly!

2. Where can I find examples and documentation to learn how to properly document the code through JSDoc for Servoy?

3. In the mid-time, how can I specified the params for the ‘result’ object (smartDocProcessCallback(result)). The method’s code is below:

```auto
/**
 * @AllowToRunInFind
 * 
 * // TODO generated, please specify type and doc for the params
 * @param {Object} result
 * @properties={typeid:24,uuid:"62930224-9EDF-466F-8EDC-9611D6726055"}
 */
function smartDocProcessCallback(result) {
	// if the use canceled using the cancel button, also stop processing other files:
	if (plugins.busy.isCanceled()) {
		plugins.SmartDoc.stopProcess();
	}
	// do we have a valid result?
	if (result) {
		var savedAutoSave = databaseManager.getAutoSave();
		databaseManager.setAutoSave(false);
		// get the ID
		var id = result.getValue('id');
		if (id) {
			var serverName = databaseManager.getDataSourceServerName(controller.getDataSource());
			/** @type {JSFoundSet<db:/fcpadb/documents_content>} */			
			var fs = databaseManager.getFoundSet(serverName,'documents_content');
			//the two variables above were unnecessary. The whole thing is defined in the relation. 
			//var fs = foundset.documents_content_ref01
			//I was wrong. The two variables above are necessary. If I don't use the found set capture by the databaseManager the method does not work.   
			var count = -1;
			if (fs.find()) {
				fs.document_content_id = id;
				count = fs.search();
			}
			
			if (count > 0) {
				// fill the record fields from the result:
				if (result.getErrorCode() == SubmitResult.ERROR_NONE) {					
					// here we need to extract them all one by one 
					// because the fields don't have the same name as the result values:
					fs.document_keywords = result.getValue('keywords');
					fs.document_subject = result.getValue('subject');
					fs.document_summary = result.getValue('summary');
					fs.metadata_author = result.getValue('author');
					fs.metadata_charset = result.getValue('charset');
					fs.metadata_content_type = result.getValue('contenttype');
					fs.metadata_creator = result.getValue('creator');
					fs.metadata_extension = result.getValue('extension');
					fs.metadata_file_name = result.getValue('newname');
					fs.metadata_file_path = result.getValue('newpath');
					fs.metadata_filesize = result.getValue('filesize');
					fs.metadata_initial_file_name = result.getValue('initialname');
					fs.metadata_initial_path_or_url = (result.getValue('url')) ? result.getValue('url') : result.getValue('path');
					fs.metadata_last_modified = result.getValue('lastmodified');
					fs.metadata_producer = result.getValue('producer');
					fs.metadata_title = result.getValue('title');
					fs.document_content = result.getValue('content');
				}
				fs.metadata_error_code = result.getErrorCode();
				fs.metadata_error_message = result.getErrorMessage();
				databaseManager.saveData(fs.getSelectedRecord());
			}
			
			// we want to fill the main record with the first document:
			if (firstDocument == id) {
				//document_title = result.getValue('title');
				document_abstract = (result.getValue('summary')) ? result.getValue('summary') : result.getValue('subject');
				document_author = result.getValue('author');
				document_source_publisher = result.getValue('producer');
				document_initial_file_url = (result.getValue('url')) ? result.getValue('url') : result.getValue('path');
				document_keywords = result.getValue('keywords');
				metadata_file_path = result.getValue('newpath');
				document_date = result.getValue('lastmodified');
				
				// setup the date related fields:
				if (document_date) {
					document_dt_dd = document_date.getDate();
					document_dt_mm = document_date.getMonth() + 1;
					document_dt_yyyy = document_date.getFullYear();
				}
				databaseManager.saveData(foundset.getSelectedRecord());
			}
		}
		databaseManager.setAutoSave(savedAutoSave);
		// if this is the last document, release the UI:
		if (result.isLastDocument()) {
			plugins.busy.unblock();
			onActionCloseFormInDlg();
		}
	}
}

```

Again,

Thanks a lot, Carlos.

---

<div class="post-metadata">

**Author:** ![ptalbot](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/ptalbot/32/4952_2.png) [@ptalbot](https://forum.servoy.com/u/ptalbot)\
**Post date:** [August 3, 2012, 3:22pm UTC](https://forum.servoy.com/t/servoy-and-the-databasemanager-getfoundset-in-servoy-6-1/16297/4 "2012-08-03T15:22:19Z")

</div>

Just use the syntax without type, like this:

```auto
@param result

```

---

<div class="post-metadata">

**Author:** ![Joas](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/joas/32/5095_2.png) [@Joas](https://forum.servoy.com/u/Joas)\
**Post date:** [August 3, 2012, 3:29pm UTC](https://forum.servoy.com/t/servoy-and-the-databasemanager-getfoundset-in-servoy-6-1/16297/5 "2012-08-03T15:29:27Z")

</div>

> jcarlos:  
> Where can I find examples and documentation to learn how to properly document the code through JSDoc for Servoy?

The best source is [the wiki](http://wiki.servoy.com/display/public/DOCS/Annotating+JavaScript+using+JSDoc).

---

<div class="post-metadata">

**Author:** ![jcarlos](https://avatars.discourse-cdn.com/v4/letter/j/46a35a/32.png) [@jcarlos](https://forum.servoy.com/u/jcarlos)\
**Post date:** [August 3, 2012, 3:44pm UTC](https://forum.servoy.com/t/servoy-and-the-databasemanager-getfoundset-in-servoy-6-1/16297/6 "2012-08-03T15:44:18Z")

</div>

> Joas:
> 
> > jcarlos:  
> > Where can I find examples and documentation to learn how to properly document the code through JSDoc for Servoy?
> 
> The best source is [the wiki](http://wiki.servoy.com/display/public/DOCS/Annotating+JavaScript+using+JSDoc).

I found it! It’s here: [http://wiki.servoy.com/display/public/DOCS/Annotating+JavaScript+using+JSDoc](http://wiki.servoy.com/display/public/DOCS/Annotating+JavaScript+using+JSDoc). Thanks!

---

<div class="post-metadata">

**Author:** ![jcarlos](https://avatars.discourse-cdn.com/v4/letter/j/46a35a/32.png) [@jcarlos](https://forum.servoy.com/u/jcarlos)\
**Post date:** [August 3, 2012, 4:03pm UTC](https://forum.servoy.com/t/servoy-and-the-databasemanager-getfoundset-in-servoy-6-1/16297/7 "2012-08-03T16:03:30Z")

</div>

> ptalbot:  
> Just use the syntax without type, like this:
> 
> ```auto
> @param result
> 
> ```

That easy ehh! But, how to know this is the question… I’ll be reading carefully the info in the Wiki.

What about here?

```auto
	} catch(e) {
		application.output('error '+e.getMessage(),LOGGINGLEVEL.ERROR);
		//application.output('error',LOGGINGLEVEL.ERROR);
	}

```

**The method getMessage() is undefined for object e**

Another easy tip?

Thanks and bienvenue!  
Carlos

---

<div class="post-metadata">

**Author:** ![ptalbot](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/ptalbot/32/4952_2.png) [@ptalbot](https://forum.servoy.com/u/ptalbot)\
**Post date:** [August 3, 2012, 5:07pm UTC](https://forum.servoy.com/t/servoy-and-the-databasemanager-getfoundset-in-servoy-6-1/16297/8 "2012-08-03T17:07:57Z")

</div>

try e.message instead.

---

<div class="post-metadata">

**Author:** ![jcarlos](https://avatars.discourse-cdn.com/v4/letter/j/46a35a/32.png) [@jcarlos](https://forum.servoy.com/u/jcarlos)\
**Post date:** [August 3, 2012, 6:05pm UTC](https://forum.servoy.com/t/servoy-and-the-databasemanager-getfoundset-in-servoy-6-1/16297/9 "2012-08-03T18:05:54Z")

</div>

> ptalbot:  
> try e.message instead.

It works! Thanks!
