Programmatically change "database script" section of a database

My intent: To force users who try to access a database to another database or web page which would give info as to why the database is not accessible.

My suggested solution: Write some code that would modify the query open event of a “database script” section of every database to force users to my information page whenever they try to open the database.

Question: Is this possible?

Subject: Yes

You would need to give default rights to this db like depositor. In the queryopen script check to see if their rights are depositor and then place an prompt box that would give them instructions on how to gain correct rights to the db or script that would remove old icon and replace with new db on desktop

For converting the design of the db you can create a template and then run nconvert on the db/dbs (via wildcard/input file) to the template that redirects the user from the old db to new db.

Subject: Two solutions

I have two solutions.

The first one is that you just update the database templates with the code you want for the databases, and the nightly design task will push the change out. You are using templates and automatic design refresh, right?

The second one would be to export the database design element you want to modify as DXL, modify the DXL programatically and then import the DXL into the database again.

Subject: I got it to work using DXL

Karl was right!!

DXL Works like a charm. This opens up so many doors. I wish I had investigated this sooner.

Subject: Two solutions

Option 1 would be perfect if I could automate it because the target databases currently number 4000+ and counting. Would take forever to do this manually.

I will explore your option 2. If you come up with any more solutions please keep them coming.

Subject: But…

But do you really have 4000+ different database templates? When you have that many databases, I would imagine most of them are based on just a handful of templates…

Subject: What are you trying to really do?

If it to decommission the server or db moves and you want move the user over to use the new server/database all you just need to do is redesign the db using one template that has the the open query code that will open the same db on the other server or just put logic in there to move them to many diffrent servers with case/or if code.

You can also look at the admin client process to decommision a server.

Subject: What I am REALLY trying to do

I am planning a “SOFT” decommission of databases that we have identified as NOT being used. We have sent out communications regarding the relevance of these database with little feedback from owners.

The plan is to wright a script that accepts, as input, a list of target database I want to soft decommission. The script would make a design copy of the database so as to preserve integrity then go into the “database script” section of each database and insert 2 commands in the post open event.

  1. NotesUIWorkspace.URLOpen

  2. NotesUIDatabase.Close command.

To sum it up. Programmatically modify the design of the database to force users to a web page with instructions as to why their database was being decommissioned and what steps to take to reverse the process.

Subject: Nconvert

Here is a url to info on the nconvert command.

http://www-01.ibm.com/support/docview.wss?uid=swg21304939

The nconvert command can use a input file (server dbname) and redesign the design to you new template.

The nconvert comes with the Notes client as well so with the client running you can drop to a dos prompt and run the command

nconvert -f * servername!!newtemplatename.ntf

in the text file list the db as servername!!filename

Subject: What about the template creation and modification

I need a solution for creating a template programmatically and modifying the “Database Script” section of a database automatically

Subject: Not really

Work on a universal template. You can see what db you are using and what server so can point to the new copy based off that info. The message to the user can be configured off that inf as well with a bunch of case or if statements.

Subject: Confused…

Are you suggesting that there is a way to create a universal template that will only update the database script portion of a database?

Subject: Answer

How I understand it is that no user will be using these dbs on the old server so you really don’t care if the views and forms and other design elements go away. All you care about is when the user accesses the db the query open code will execute and will repoint the user over to the correct server and produce an message that they where moved over to a new server. If users are still going to access the db on the old server than a universal template will not work.

Subject: Not exactly

Users have not responded to our requests so I want to give them a little push by blocking there access to the database. Not from a security standpoint but by modifying the post open event to load an information webpage with instructions as to why they are locked out and what steps need to be taken to regain access.

I am not moving any databases to other servers or redirecting the users to an application on another server.