How can I do a DBLookup in LotusScript?

Here’s what I have to do…

On my domain we have 2 databases to manage ID terminations and ID file backups. The ID termination DB is basically a copy of the names.nsf where we just copy/paste person documents before we delete them, and the ID backup DB is the ID Manager application database provided by HelpSoft (www.helpsoft.com).

The ID Manager offers the possibility to manage user terminations and archiving of old ID documents, but we haven’t used that feature since we installed the application 3 years ago. We would like to start using it now, but as you might think, we need to cleanup the database (the User ID documents) to remove all of the ones for users that were terminated more than 90 days ago (or so…)

What I want to do (or did already):

  • In the termination database: Create a hidden view so I can lookup the Created Date of the documents (to get termination date) from another database. I did that and called the view ($DBLookup)

  • In the ID Manager: modify the UserID form to add hidden fields that will be used to populate if the user is present in the active NAB, if he’s present in the Termination DB, and to store the Termination date (if not null). I named those editable text fields respectively InNAB, InTermed and CreatedInTermed

  • In the ID Manager: create a hidden view showing the Name, Created Date, InNAB value, InTermed value, and CreatedInTermed value. Done that, called the view ($User ID Maintenance)

Thing is now I have to populate those 3 new fields I’ve added since you can’t use a lookup in the view, and I can’t possibly open, edit and save every document manually in order to trigger a formula that would update the fields when the On Document Save event is triggered… (I could, but I’d have to do it over 2000 times… not an option). So I want to make an agent (manual, from action menu) that will do that for me. This is where you come in…

I’ve been looking for ways to do DBLookups in LotusScript, but I can’t seem to find the function that will let me do this. I need the agent to perform the following action for every selected User ID documents in the ID Manager:

Note: The UserID form contains the same basic fields that the Person document has in the NAB (Firstname, Lastname, Shortname, etc…)

  1. Lookup the NAB using the People view and return the any unique field that would allow me to determine if the user is present or not in the NAB (if null, it’s not, if not it is). Let’s say we put a 0 or a 1 in a variable we call NABCheckValue depending if the return was null or not.

  2. Do the same with the termination db, but using the ($DBLookup) view, and return the Created Date if found. Put results in TermedCheckValue, and TermedCreatedValue variables.

  3. Populate the InNAB, InTermed and CreatedInTermed fields of the opened document with the NABCheckValue, TermedCheckValue and TermedCreatedValue variables and save the document. (repeat for all selected in the view)

Without writing it all for me (still want a bit of challenge hehe), would anyone be able to point me in the right direction or perhaps give me a code example I could use?

Thanks!

Subject: How can I do a DBLookup in LotusScript?

DBLookup in Lotus script feature can be achieved by

‘GetDocumentByKey’ method of NotesView class, if getting the document from a view OR

‘GetDocumentByUnid’(UniqueID) or ‘GetDoucmentByID’ (NoteID), if getting it from Notes Database.

Please go thru the designer help for better understanding.

Subject: RE: How can I do a DBLookup in LotusScript?

Thank you! That should give me enough to get started. Much appreciated!

Subject: How can I do a DBLookup in LotusScript?

Look at NotesView.GetAllDocumentsByKey

I didn’t read you entire post, so I don’t know if this is the right path for you, but this function basically does the same thing. It looks through a sorted view you reference, looking for the key.