Link to home
Start Free TrialLog in
Avatar of mchampou
mchampou

asked on

Removing a database icon from a workspace

Hi everyone!

   This one is a "toughy"... I need to remove a database icon from the workspace programmatically... I know there are no methods in LotusScript to do that but I trust someone has found a way to "hack" lotus notes and do that.

I'm thinking, in LotusScript (as most solution requires), to open the desktop.dsk file (it's a database you know), try (if God helps me) to find the document that represents the icon I wish to remove and remove the document ?

I'm also thinking to put a button in the database (the one I wish to remove) that will 1. Quit the database (return to the workspace) 2. Call @Command([EditClear]) ... that should do the trick but I am too afraid that something goes wrong and I end up deleting another icon ...

Any toughts / solutions will be appreciated,

mchampou
Avatar of mchampou
mchampou

ASKER

If anyone wonders, I've tried the second solution with success but I still don't like it ... here's the code in the button :

@Command([FileCloseWindow]);
@Command([FileCloseWindow]);
@PostedCommand([EditClear])

The first FileCloseWindow closes the document the user had opened to click on the button.
The second FileClose closes the database.
The EditClear acts like if the user had pressed "Delete" on his keyboard to remove the database icon ... voila!

But it's too simple ... I need something more robust (like script).

Thanks!

No such thing...believe me, I tried this before and drived me nuts, before someone told me about the commands.  Its possible in R5 so I hear. No script what so ever to do this.  By the way, instead of a 2 close windows command, and a posted one, u can just use @Command([WindowWorkspace]).  Will that earn me the points?:p
I don't think you will be able to do this from R4 documentet script features.

Still i would prefer the following formula wich makes sure the correct database icon is highlighted before deletion :

@Command([FileCloseWindow]);
@Command([FileCloseWindow]);
@Command([WindowWorkspace]);
@Command( [AddDatabase] ; server : db );
@Command([FileDatabaseRemove])

[EditClear] may interfere with wrong object types as documents.
The problem with a formula is that one can not make sure that the database to be removed is not currently open in another window. If this is the case the formula won't work. I tried this method, but gave up as it is not reliable.

Secondly you get this stupid confirmation dialog when using FileDatabaseRemove. So still a user can make your formula not working.
MW, u r absolutely right!
Hi Gunsen,

  I am sorry to reject you answer. I tried it out and it does not work. It leaves the database opened so when you do the @Command([FileDatabaseRemove]) it gives an error message and does not remove the icon : I must go back to my window list, close the opened view and then it removes itself ...

  I tried with a mix of @PostedCommand to no avail. I also tried to add a couple more of [FileCloseWindow]... If you could just check up your code, perharps I'm not getting something here.

  BTW: You are right on the target when you say that the [AddDatabase] will select the right database... but up to now (perhaps I'm lucky) I haven't had any problems : the correct icon was selected. You were also right about the [EditClear] that might delete the wrong stuff ... it happened to me once as I was testing and I didn't put enough [FileCloseWindow].

I'll be waiting for your response ... pls keep in mind that I won't be in the office for the next 4 days (tommorrow and friday off + weekend).

Sincere thanks,

mchampou
ASKER CERTIFIED SOLUTION
Avatar of ghassan99
ghassan99

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Well, on my client (R 4.6.3), the icon will get deleted after last session/window is closed.  The error msg says - the icon will be deleted later... - and it does.
I have a LotusScript solution that works.  First, I found a LotusScript script library that you include in your database.  It functions like SendKeys in VB, but SendKeys is not supported in Notes, and does not work.  This script library does work -- very much like SendKeys.

When the script library (that I can send to anyone who wants it) is pasted into the database, and the Use statement decared in the Globals Options with the Use statement, the script is available and the "PushKeys" statements can be used in script in much the same way SendKeys works.

I used this solution in an application that I have to distribute files to multiple users in a self-extracting archive.  After the document that they open from a doclink is closed, the icon to the database remains on their workspace.  Since the last thing this application does is run a LotusScript routine to send mail back to IT (as an audit trail of which users actually unzipped the files), I simply wrote included the script witten in a sample below.  The sample below of for illustrative purposes.  My code is seamless to the user.

For demonstation, I created an action in a view, with a button visible in that view to test and run the script.  It adds the database icon to the workspace (even though it's already there it doesn't generate an error).  The script attahced to the button is this:

Sub Click(Source As Button)
     Dim workspace As New NotesUIWorkspace
     Dim db As NotesDatabase
     Dim session As New NotesSession
     Dim sn As NotesDatabase
     Set db = session.CurrentDatabase
     
     'if db is on several servers, this code will
     'assign the name of the server to the variable
     'sn by retrieving it from the sessions current database properties
     Set sn = session.CurrentDatabase  'set value of sn
     server = sn.Server  'get current server name
     
     'this code uses an empty string for the server assuming this script is running on a local machine
     'replce the empty string with the server variable if the database is a replica on a server
     Call workspace.AddDatabase("", "test navigators.nsf")    
     
     PushKeys "{ESCAPE}"  'Closes the current database and returns to the workspace
     PushKeys "{DELETE}"   'Removes the selected icon from the workspace
     PushKeys "{ENTER}"     'Answers the user prompt by accespting the Yes default
     
     Exit Sub
End Sub

=====================================================
If you would like to accept this answer, I will send you the script library.
>>Thanks
The above solution is nice.. but can you provide me with the script library... my id is vikram.solanki@inbox.com

vikram.r.solanki@gmail.com-- can you send me the script library to this id...