second framework db

I’ve started a new framework solution, that has to run on the same server as the first framework solution.
I’ve create a new db: svy_fr_service (a copy of the svy_framework db)
I’ve create my new solution and in that solution I’ve create a function svy_nav_getFrameworkDBName to return the new dbname.
But the solution does not switch to this db! When I look at the svy_nav_onOpen() function I notice that the switchServer will only occur for deeplinks?

function svy_nav_onOpen(_startArgs) {
	//retrieve the owner_id and db-servernames from the deeplink - will not work in developer
	var _owner_id, _userDB, _frameworkDB;
	if(_startArgs) {
		var _args = _startArgs.split("|");

		_owner_id = _args[0];
		_userDB = _args[1];
		_frameworkDB = _args[2];
	}
	
	forms.svy_nav_fr_postLogin.controller.show()

	// set owner id's
	globals.owner_id = globals.svy_sec_owner_id = globals.svy_sec_lgn_owner_id
	
	//check if we should switch the framework db
	if (globals["svy_nav_getFrameworkDBName"]) {
		//This function is used for people that named their frameworkdb different than "svy_framework"
		globals.nav_db_framework = globals["svy_nav_getFrameworkDBName"]();
		}
	if (_frameworkDB && (_frameworkDB != globals.nav_db_framework)) {
		databaseManager.switchServer(globals.nav_db_framework, _frameworkDB);
	}

My new framework db is in globals.nav_db_framework, but because _frameworkDB is not set (as I am not coming from a deeplink) the switch server is not triggered.

Am I doing this correctly? Or is this a bug?

Switching the framework database server indeed only works with deeplinking.

The reason is that even though you can set another framework database in your solution, this is always a step too late as the login procedure will be executed before your main solution is actually loaded. This would require setting the correct framework database in your login solution. But if you want to reuse the framework solutions and modules for multiple custom solutions it can only be done through deeplinking.

Ok, as I want to reuse the framework solutions and modules, I will have to use deeplinking. But what is the best way to work with this in my Developer as deeplinking will not work there?

I’m interesting too in this information, actually i have 3 differents apps, with 3 differents db, in developer not is problem but when i want to put in server, i don’t know how to make the selection.

Vincent,
Is it save to use the svy_nav_lgn_onSolutionOpen to set the correct framework db depending on the current solution name? Or would you not recomment that?

What you could do is to mimic the deeplink in the onOpen method of the login solution (method “svy_nav_lgn_onSolutionOpen”). You could use something like:

if (application.isInDeveloper()) {
	var ownerId = '';
	var userDb = '';
	var frameworkDb = '';
	switch (application.getSolutionName()) {
		case 'solution1':
			ownerId = 'B0687F10-2EEF-4C1B-8D56-83C6626EFC97';
			userDb = 'user_db1';
			frameworkDb = 'svy_framework1';
			break;
		case 'solution2':
			ownerId = '7872A87F-6BC0-4E97-AE41-D72D287D1074';
			userDb = 'user_db2';
			frameworkDb = 'svy_framework2';
			break;
		case 'sampleuse_navigation':
			ownerId = '1962653F-1CB2-4C52-85F8-5E55A6D7BAB2';
			userDb = 'example_data';
			frameworkDb = 'svy_framework';
			break;
	}
	
	globals.svy_sec_l_startArg = ownerId + '|' + userDb + '|' + frameworkDb;
}

I just tested this in version 6.1 but some weird exception is thrown and I’m not sure why. However, this should just work.

but why i need to define the ownerid and userdb? can not be the default?

And i’m interesting to change the database before the user make login, in this case this is valid?

You can leave the owner empty here but the empty value should be defined as the first parameter. If you are using the same user database for all your solutions, then you can also leave this value empty.

And the framework database will be used depending on the name in the parameter.

and this piece of code go inside the function svy_nav_lgn_onSolutionOpen, no?

Yes, you could put that inside or in a separated method which will be called from that method.

Okey, thanks for all the info, later i try it in my own server!

But i still have a doubt, in the servoy server, is needed to define a svy_framework database? because if i want to import a solution servoy admin say that the server not exist.

There is always a default database needed. In the framework, database “svy_framework” has been defined as that default database thus needs to be present on the Application Server.

If you are using multipe databases you can also create the other database after the import of the solution.

Okey, but for every database i need to import the correct information, no?

But i don’t understand what i have to put in ownerId and userDb, can you explain me or send me a link that explain this?

Vincent,
I’ve added your code to svy_nav_lgn_onSolutionOpen and the login seems to go Ok against this new frameworkDB, but I’m getting strange errors when I add my first form and try to load it. I get the following error:

Een foundset van tabel employees kan niet in een form geladen worden met een tabel employees
Wrapped java.lang.RuntimeException: Fout bij het laden van de gevonden reeks,Een foundset van tabel employees kan niet in een form geladen worden met een tabel employees (D:\servoy6_workspace\svy_nav_navigation\globals.js#1967)
at D:\servoy6_workspace\svy_nav_navigation\globals.js:1967 (svy_nav_showForm)
at D:\servoy6_workspace\FocusService\forms\menu.js:58 (showProgram)
at D:\servoy6_workspace\FocusService\forms\menu.js:105 (showProgramFilter)

So maybe I had some references to the original table, so I disabled the data-database for the default Framework environment. But then I get errors at login because it is loading bookmarks that references that database. Even though I have cleared the nav_bookmarks table in my new frameworkDB. So it seems that somehow it is still referencing the original frameworkDB!!

When I trace svy_nav_onOpen I notice that is doesnot have any startArgs, shouldn’t the same arguments we put in svy_nav_lgn_onSolutionOpen be available here?

There is something really strange happening in svy_nav_init_programs().
When I check the content of _dataset I get the correct data. But when I check the content of forms.svy_nav_c_program_dtl.foundset I suddenly see different values! It looks like the _dataset is data from my second framework db, but the forms.svy_nav_c_program_dtl.foundset is from my first framework!!.

I think I am missing some crucial step to setup the second framework environment! Can you give me a step by step on what to do to setup a second framework environment on the same server please?

All databases for the framework you are using, have to exist, including the correct data. But as the default database is “svy_framework” (on which you have developed your code) the initial import is done on this database and also the initial data can be automatically imported. But you will need to add the alternative databases for “svy_framework” yourself and import the correct data.

The parameter “userDb” can be used if you also using separate databases for user data. But if you are just using 1 user database then you don’t have to use this parameter.

The parameter “ownerId” can be used to prefill the owner at the login form. But again, if you don’t want to use it you can just leave it blank.

Jos, I did see that I forgot an important step in the process! On the onOpen method of your main solution(s) (method “onSolutionOpen”) you would need to add the code below, because otherwise it doesn’t change the database properly.

if (application.isInDeveloper()) {
	globals.svy_nav_onOpen(globals.svy_sec_l_startArg);
} else {
	globals.svy_nav_onOpen(_startArgs);
}

I suspect that this should fix your problem.

Hi Vincent,

Thank you for your reply. I think I got it working now. Could you check if this is a correct setup:

Original Situation:
frameworkDB: svy_framework
dataDB: myDB

my NavSolution:
in my globals I’ve got the following function:

function svy_nav_getUserDBName() {
	return 'myDB'
}

My second environment:
frameworkDB: svy_fr_2
dataDB: myDB_2

my NavSolution_2:

function svy_nav_getUserDBName() {
	return 'myDB_2'
}

in svy_nav_lgn_onSolutionOpen I’ve included the following code:

	if(application.isInDeveloper()) {
		var ownerId = '';
		var userDb = '';
		var frameworkDb = '';
		switch (_solution) {
			case 'NavSolution_2':
				userDb = 'myDB_2';
				frameworkDb = 'svy_fr_2';
				break;
			default:
				userDb = 'myDB';
				frameworkDb = 'svy_framework';
				break;
		}
		globals.svy_sec_l_startArg = ownerId + '|' + userDb + '|' + frameworkDb; 
	}

And last I’ve added the following onOpen function to my NavSolution_2:

function fs_onOpen(_startArgs) {
	if (application.isInDeveloper()) {
	   globals.svy_nav_onOpen(globals.svy_sec_l_startArg);
	} else {
	   globals.svy_nav_onOpen(_startArgs);
	}
}

Like I said this seems to be working, but I would like your (or Sannekes) expert-thoughts on this setup.

Thanx, Jos