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:
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:
CLEAR(recDatabaseInfoSetup); IF recDatabaseInfoSetup.GET THEN IF recDatabaseInfoSetup."Show Database Info Form" THEN IF GUIALLOWED THEN FORM.RUN(FORM::"Database Info");
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):
//FIXED WIDTH AND HEIGHT. I CHOSE THESE VALUES: lintFormWidth := 10960; lintFormHeight := 4647;
//RESET SHAPE VALUES CurrForm.Blue.VISIBLE:=FALSE; CurrForm.Red.VISIBLE:=FALSE; //... //YOU CAN ADD THE REST OF THE COLORS IN THE SAME WAY
//MOVE SHAPES CASE recDatabaseInfoSetup.Color OF recDatabaseInfoSetup.Color::Red: BEGIN CurrForm.Red.VISIBLE:=TRUE; CurrForm.Red.XPOS := 0; CurrForm.Red.YPOS := 0; CurrForm.Red.WIDTH := lintFormWidth; CurrForm.Red.HEIGHT := lintFormHeight; END; recDatabaseInfoSetup.Color::Blue: BEGIN CurrForm.Blue.VISIBLE:=TRUE; CurrForm.Blue.XPOS := 0; CurrForm.Blue.YPOS := 0; CurrForm.Blue.WIDTH := lintFormWidth; CurrForm.Blue.HEIGHT := lintFormHeight; END; //... //YOU CAN ADD THE REST OF THE COLORS IN THE SAME WAY END;
//RESIZE FORM CurrForm.WIDTH := lintFormWidth; CurrForm.HEIGHT := lintFormHeight;
It all comes down on resizing the form and resizing shapes.
//recLicense (Record of the table "License Information") recLicense.SETRANGE("Line No.",5,6); IF recLicense.FIND('-') THEN REPEAT IF recLicense.Text <> '' THEN txtlicense[recLicense."Line No."] := COPYSTR(recLicense.Text, 27, STRLEN(recLicense.Text)-26); UNTIL recLicense.NEXT = 0;
With txtlicense and txtLicense you can find your license information.
CLEAR(lrecSession); IF lrecSession.RECORDLEVELLOCKING THEN lrecSession.SETFILTER("Application Name",'@*NAV*'); intSessionCount := lrecSession.COUNT;
lrecSession.SETRANGE("My Session", TRUE); IF lrecSession.FINDFIRST THEN BEGIN txtUserID := lrecSession."User ID"; txtDatabaseName := lrecSession."Database Name"; END ELSE BEGIN txtUserID := ''; txtDatabaseName := ''; END;
This way, you also get the full login (with domain) when logged in with Windows Authentication ... Which I prefer.
Voilà, that's all. Not really "hocus pocus". Just simple and effective.
Hope you like it.
Works like a charm, really good idea, thanks alot!
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... ;-)
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?
That is fantastic Viktoas!
I have implemented your suggestion on my Where Am I tool and it works a treat. I just need to package it up with some instructions and pop it on the downloads page!
Thanks for sharing this and leaving the comment on my blog to let me know you had done it.
awarnica, you can use Fromat -> Bring to Front / Send to Back functions on controls.
I have solution which allows to have information form always opened.
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:
NTimer::Timer(Milliseconds : Integer)
Here FormClosed and OpenForm are functions with no parameters; NTimer is global variable, Navision Timer automation.
On form's OnCloseForm trigger function GeneralInformationMgt.FormClosed is called.
From codeunit 1 I run GeneralInformationMgt codeunit instead of opening information form.
Hope my explanation is clear enough.
Thanks for posting the answer. I was going to try this out ... but you were too quickly.
You need to add the shapes first - then the labels afterwards, and then the labels will appear on top of the shapes instead of being hidden :)
When I do this, my shapes seem to be on top of the textboxes (so I cannot see the text) - I know I am missing something simple...
Hi it's me again. OK so I had a go at doing some things with this idea. If you're interested, take a look at my post on gaspodethewonderdog.blogspot.com/.../where-am-i.html
I did come across a few issues so maybe some of the clever readers of your blog could answer the bits that don't work. Thanks for the inspiration and thanks heaps for posting the idea. Cheers, Dave.
@Gaspode: I have been strugling with that myself and I don't see a solution (yet). The only way (for now) is to change the option "Close Forms On Esc" to "No".
But honestly, we don't do that.
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?
The best solutions are simplest - this is really neat and really useful - thanks a lot