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)
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:
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.
Where can I find examples and documentation to learn how to properly document the code through JSDoc for Servoy?
In the mid-time, how can I specified the params for the ‘result’ object (smartDocProcessCallback(result)). The method’s code is below:
/**
* @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();
}
}
}