Servoy 6.1 warnings in js calculation files

Re: Servoy 6.1 warnings in js calculation files re Reference to undeclared variable or property: databaseManager, foundset and their respective properties

I have these method to provide Boolean values to columns in the database via calculation. The methods have worked fine in both Servoy 5.x and 6.1, but now (in 6.1) I get warnings and I can find a way to get rid of them.

This is one of the methods:

function sec_proceeding_bln(){
	//get dataset based on a query to check for SEC
	var vMaxReturnedRows = 10;
	var vQuery = 'SELECT fcpa_matters.fcpa_matter_id FROM ( fcpadb.gov_proceedings gov_proceedings JOIN fcpadb.fcpa_matters fcpa_matters ON (gov_proceedings.fcpa_matter_id = fcpa_matters.fcpa_matter_id)) JOIN fcpadb.proceedings_agencies proceedings_agencies ON (proceedings_agencies.proceeding_id = gov_proceedings.proceeding_id) WHERE fcpa_matters.fcpa_matter_id = ' + fcpa_matter_id + ' AND proceedings_agencies.enforcement_agency_id = 11';		
	var args = new Array();
	args[0] = proceedings_ref01.proceeding_id;	
	var dataset = databaseManager.getDataSetByQuery(databaseManager.getDataSourceServerName(foundset.getDataSource()), vQuery, null, vMaxReturnedRows);
	if (dataset.getMaxRowIndex() > 0){
		sec_proceeding_bln = 1;
		databaseManager.saveData();
	}else{sec_proceeding_bln = 0};
}

First, Servoy advices me to create local or top level variables for databaseManager and foundset. If I create the variables, then I get these warnings -and not suggestions:

Multiple markers at this line

  • The method getDataSource() is undefined for object foundset
  • The method getDataSetByQuery() is undefined for object databaseManager
  • The method getDataSourceServerName() is undefined for object
    databaseManager

Any advice? Should I change the method? If so, how can I then ‘getDataSetByQuery’ without using the databaseManager object?

Any advice would be appreciated.

Best, Carlos

The use of databaseManager and foundset from within a calculation is discouraged… That is why they are missing from code completion/JS compile. We want the calculation to be based as much as possible on the current record and they could be used in an undesired way from within a calculation - although this doesn’t happen in your case. (I can only think of the fact that the calculation could be a bit slow as it triggers a query)

foundset.getDataSource() can be replaced by getDataSource().

Please create a case for accessing databaseManager from calculations. We should add a subset of calls that are supported from within calculations.

Hi,

Please create a case for accessing databaseManager from calculations. We should add a subset of calls that are supported from within calculations.

Status on this one in Servoy 6 and 7 ?

It’s still the same. Here are some cases about this that you could watch:

SVY-905
SVY-883

SVY-883 is not public.

It is public now.

Ok, thanks Andrei.

Regards,