var form_name = elements.tabs_70.getSelectedTabFormName(); // the form active in the tabpanel
forms[form_name].controller.newRecord(); // add new record on selected form
forms[form_name].status_field = 1; // sets status field to active
Why not post the code from your method so it can be reviewed.
Seems odd that you can target the record creation and then not use the same SOM to set the column value
Also I know that this is no solution to the main issue, but if the new record always has to contain the ‘active’ tag then why not set it as an autoenter value ?
As said earlier the original form (nav)is attached to companies table. I have reconfigured my form so the company,people and projects forms are in the tabless tab panel. Switching with methods works well. Buttons are on the nav form.
Moving the record index is not working… I am using
var formname = elements.tabs_Forms.getSelectedTabFormName();
forms[formname].controller.recordIndex = controller.recordIndex + 1
and
var formname = elements.tabs_Forms.getSelectedTabFormName();
forms[formname].controller.recordIndex = controller.recordIndex - 1
This indicates to me you would have the forms (Companies.Projects…etc) in the tab panel and the navigation buttons on the form itself.
Is that correct?
I do not use controller forms anymore but I put the “navigation form” in a relationless tabpanel on a main form containing also the tabpanel for companies,projects, etc…
Thanks. Seems to be working. For those that are interested here is my final code…
var formname = elements.tabs_Forms.getSelectedTabFormName();
var company = forms[formname].companyname
var project = forms[formname].projectname
var person = forms[formname].firstname + " " + forms[formname].lastname
if (formname == "companies")
{
identity = company
}
else if (formname == "people")
{
identity = person
}
else if (formname == "projects")
{
identity = project
}
var answer = plugins.dialogs.showDialog('Delete','Do you wish to delete '+identity+' !','Yes','No')
if (answer == "Yes")
{
forms[formname].status = "Deleted";
plugins.dialogs.showDialog('Success',identity+' has been Deleted !\n\n If this was a mistake contact your Administrator !','OK')
forms[formname].controller.loadRecords();
}
For your “share the love” series… another flavour for your code:
var formname = elements.tabs_Forms.getSelectedTabFormName();
switch( formname )
{
case "companies":
identity = forms[formname].companyname;
break;
case "people":
identity = forms[formname].firstname + " " + forms[formname].lastname;
break;
case "projects":
identity = forms[formname].projectname;
break;
}
if (plugins.dialogs.showDialog('Delete','Do you wish to delete '+identity+' !','Yes','No') == "Yes")
{
forms[formname].status = "Deleted";
plugins.dialogs.showDialog('Success',forms[formname].identity+' has been Deleted !\n\n If this was a mistake contact your Administrator !','OK')
forms[formname].controller.loadRecords();
}
you mention that the nav form is tied to the companies table… is this a case of the form must be tied to a table… so it is arbitrarily tied to companies?
If so, I recently had a similar setup. Because it was a nav form with tabless tab panels the UI led me to believe that the current table was something different. Without thinking I started hitting the keyboard shortcut for delete record to delete a couple of new test records, and, well, realized I was deleting company records by accident (no harm, as this is a system under development).
My kludgy solution was to create a new table named “bit_bucket” with one field (a primary key) and one record. That way if my method code or user actions referred to this form’s controller by accident, I would not damage otherwise important data. I would simply mess up my “bit_bucket”.
this should not be a problem, since you can attach your own method to the onDeleteRecordCmd of your forms… if you make this method a global based in module, you can use it anywhere, and it will stay connected when you duplicate your forms
Yes, I’m aware that we can block menu commands and keyboard shortcuts. But there is something about assigning an arbitrary table to a nav form that just makes me uncomfortable. Should I write a method that behaves badly on the nav form, the potential exists for the “arbitrary table” to be modified in some unwanted way. If I assign the nav form to a useless table like “bit_bucket” then I feel much safer.
I had the same experience of record deletion and solved it by attaching a method to the ondelete trigger…as suggested by Christian. I have configured my solution never to delete master records, only archive them.
Automazione’s law # ONE:
when creating a new form always “toggle form commands” form menu elements.
With a single click all the default commands are deactivated… I personally feel more “comfortable” while I have complete control over my users (and I do not leave a dangerous “delete all records” wild and free out there…
There are probably 1,000s of ways to do this, but I would expect a navigation form to be based on a real table.
All my navigation forms are based on the “menu” table, they are in a separate module so they are fully reusable.
There is a global variable called current_screen_id. When you jump from screen to screen you set current_screen_id to the menu_id of the screen you are going to. Then there is a global relationship from current_screen_id back to menu_id. This way the navigation forms will pick up any data relevant to the current screen.
I have a set of tables containing meta-data;
menu-related stuff (where does the screen belong in the menu hierarcy, enough info the build the menus on the fly)
user’s previous choices (these are stored in virtual columns, the system remembers what the user last searched for etc,… until the user logs out)
search definitions (SQL-based search)
list of actions (generates action-buttons)
etc.
When I add a new data type to my projects I do the following:
define the table.
create a new form
place my navigation panels in header and footer
go to the menu screen to add a record for the new screen