It seems that if in settings you set the First Form to a form and then later want to change it, you can change it to another form, but not back to none.
This is a problem for us because we turned on security and depending on who logs in we want to show them the right first form for them. We have the code working fine, but no matter what the code says, it seems the first form that is always opened is the form listed in the First Form setting.
I know you can select none. The problem is it doesn’t work. Once you have selected a form you can later change the first form to a different form, but if you change it back to none and then apply the changes and close the window the change doesn’t stick. If you open the settings window again the form name is back in the First Form field rather than none.
That is what I am doing, but its not working. The first form setting is over-riding the code.
Here is the code that is called from the On Open method of the solution:
var p = security.getUserGroups(security.getUserId());
var myGroup = p.getValue(1,2);
if (myGroup == "Accounting") {
forms.honoraria.controller.show()
}
else {
forms.projects.controller.show()
}
The code is definately being activated and going to the right place, but the first form that is displayed is always the one in the First Form setting.
It seems the only way to reset the First Form solution setting back to is to do it on the repository directly:
delete from servoy_element_properties
where content_id = 245
I know we shouldn’t be messing with the repository data directly, but in this case it seemed there was no other option – and it seems to have worked fine.
I’ve been wrestling with the same problem. With a suggested direction from David Workman we have a work-around.
Create a new blank form called Startup, (or whatever) and create a method called Startup_method like this;
//pulls the client_id, user_id, and user permissions level
forms.clnt_cli_frm_1.clnt_login_get_userdata();
//depending on the client_id takes user to correct form
var clientId = globals.client_id
if ( clientId == 1 )
{
forms.clnt_admin_c3net.controller.show()
}
else
{
forms.cont_con_frm_contact.controller.show()
}
Which is identical to your code. Then choose the Startup as the first form and Startup_method as the On Open Method. Then also, (don’t know why both, but is necessary) have Startup run Startup_method on show. This gets the desired result.