Communities

Partners

Which database are you logged into?

In a conference like Direcionts EMEA, I noticed again how interested people can be in sometimes such a simple solution. In our company, we implement every installation with a default set of tools (enhancements). One of these tools is a very simple and little something called "Database Info"-form.

The goal is to differentiate what kind of database you logged in: Test Database, a Test Company, a Development Database, ... . Actually, you just want a visual difference between two environments. In the old days (version 3.X and less), we had a menu, which we could give a certain color, caption or whatever. Now, we don't have a form that pops up, so no form we can modify. I present to you a little solution that might be able to help you with this, and the end result looks like this:

The red area, just right from the menu suite, is the "solution" I'm talking about - in case it was not clear . To accomplish the main idea, there are only three things you have to do:

Create a form with these properties:

Borderstyle: None

CaptionBar: None

Mimizable: No

Maximizable: No

Sizeable: No

Editable: No

Xpos: 0

Ypos: 0

You put some descriptions on the form with captions.

In CodeUnit 1 in Trigger "CompanyOpen" you call the form like:

IF GUIALLOWED THEN FORM.RUN(FORM::"Database Info");

That's basically all. Easy, isn't it?

But let's make it somewhat more useful and generic. Let's put some info on the form, work with colors and make that configurable ... So that the result is somewhat more like above:

Create a setup table with these fields:

Primary Key (Code)

Show Database info Form (Boolean): use this field to be able to switch off the use of the form.

Title (Text): Will be shown on the form.

Color (Option): The color of the form to make it even more "visible". I have chosen to make it simple. Just a fixed number of colors with an option field. You could make this with a color picker, but hey, we're not creating a business critical form here, are we ?

Modify codeunit 1, change your already added code to:

CLEAR(recDatabaseInfoSetup); IF recDatabaseInfoSetup.GET THEN IF recDatabaseInfoSetup."Show Database Info Form" THEN IF GUIALLOWED THEN FORM.RUN(FORM::"Database Info");

Modify the form like this:

The main idea is to "generate" the form when we are opening it. We'll set the colors, fill in the fields, make the form the right size and put it in it's place. Actually, the design on the form might even look like this (it doesn't matter):

To make the colors work:

For all colors in your option field, create a shape and put it somewhere on your form. Also, give a name to your shapes (preferably the color names to make the code more readable);

I love this tip and have been playing about with it. I've added a couple of extra features and I'll post something about it when it's done, but I have a question. Is there any way of stopping someone from clicking on the form and pressing ESC which then closes it? Other than setting Close Forms on Esc to No. I tried putting EXIT(FALSE) in the or putting something in the OnQueryCloseForm() but that is BAAAAD and you can't exit the company or NAV. Any ideas?

Idea is following - form should be allowed to close, because otherwise Navision can't be closed. But when form is closed, Navision timer is activated, which after some time (I use 100 milliseconds) opens the form back and deactivates timer.

I've created single instance codeunit (GeneralInformationMgt) with following code:

OnRun()

CLEAR(NTimer);

CREATE(NTimer);

NTimer.Interval(100);

OpenForm;

FormClosed()

NTimer.Enabled(TRUE);

OpenForm()

NTimer.Enabled(FALSE);

FORM.RUN(FORM::"General Information");

NTimer::Timer(Milliseconds : Integer)

OpenForm;

Here FormClosed and OpenForm are functions with no parameters; NTimer is global variable, Navision Timer automation.

I've been trying to contact you by various means - I sent an e-mail to your Dynamics User account, I tried an e-mail to question on your MSDynamicsWorld.com article and I tried a private message to your Dynamics User account - all with no luck. This my final last ditch attempt. If you get this could you please send me a private message through this forum?

And one tip - you can make it much better and use editbox without borders etc., with BIG font size, and e.g. with character 'g' in 'Webdings' font to fill the background with selected color. Than you can set the FOREGROUND color in OnFormat and you have truecolor background possibility without any big code for each color... ;-)