In our installation, we have three environments on different servers - production, test, and developemnt. People are getting confused and doing work in test when they should be in prod, and vice versa. I am trying to write logic that will change the main menu color, based on which environment. The differentiating factor is the Server Name. What parameter can I use to determine which server is currently being accessed? Open to other suggestions as well. Is there a better way this could be done?
This works in SQL, I don’t know if it would also work with a C/SIDE Navision server. Design the main menu, open the globals and add the following variables MyServer Record Server MyDatabase Record Database
Then, in OnOpenForm, paste the following code: MyServer.SETRANGE("My Server",TRUE); <- that's the parameter you are looking for MyServer.FIND('-'); MyDatabase.SETRANGE("My Database",TRUE); MyDatabase.FIND('-');
Then, in the DataCaptionExpr of the form itself you enter this: MyServer."Server Name" + ' - ' + MyDatabase."Database Name"
And your server name plus your database name should appear in the titlebar of the main menu. Of course, you can also put that into a textbox on the form itself. You could even get fancy and create a table with server names and color numbers and retrieve that when you open the form, but you get the jist here [:)] Good luck
Hi Larry, You can use the CONTEXTURL to get the Servername. The following code will do what you need: ltxtTemp := CONTEXTURL; i := STRPOS(ltxtTemp,‘servername=’); IF i > 0 THEN BEGIN ltxtTemp := COPYSTR(ltxtTemp,i + 11,999); i := STRPOS(ltxtTemp,’&’); EXIT(COPYSTR(ltxtTemp,1,i - 1)); END ELSE EXIT(’’);
Adding, What we did with this code, is to give a message by opening a certain database, and have added some text to the Main Menu showing the server name.
hi YOu can add and a lablel on the main menu of each of different database. with caption Production, Test and development accordingly. Best Regards
Thanks, everyone for the help. I used Sven’s logic - CONTEXTURL, very cool! Then, I made two versions of the Shape for the main menu options, each w/ different background color. Depending on whether in prod or non-prod, logic makes one of the two visible. So provides a very clear visual indicator of which environment. Thanks again!