Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Script: Conditionally create populated doc in another database

Posted on 2001-06-26
7
207 Views
Last Modified: 2013-12-18
Greetings.
I have two databases that track the progress of two different processes.

One database tracks the status of design documents. In that database, there are fields where people can put their names to automatically receive updates every time the document changes. These fields are broken down by programmer, GUI developer, documentation, etc.

The other database is used between the programmers and the GUI staff so the programmers can notify the GUI developers when they finish with the programming, so the GUI staff can begin.

The first database includes an agent that queries the user for a name, then passes that name (by environment variable) to another agent that adds that name to the Programmer field for every selected record. (Similar agents exist for the other departments.)

I'd like for the add-a-programmer agent to check to see if a GUI developer has already been assigned to the record and, if one has, create a new record in the second database, assigned to the programmer who was just added to the record in the first database.

As it stands, the add-a-programmer agent looks like this:

========= BEGIN CODE ==========
SELECT @All;
NewName := @Environment("PassedName");
OldList := @Implode(Programmer; "|");
NewText := @If(OldList = ""; NewName; OldList + "|" + NewName);
NewList := @Explode(NewText; "|");
FIELD Programmer := @Unique(NewList);
FIELD ProgrammerDisplay := @Unique(@Name([CN]; NewList));
FIELD LastEditor := @UserName
========== END CODE ==========

The record in the second database, which I would like to compose, would use the Release and Component fields from the record in the first database. (It is a much simpler form.)

What would the script to implement this look like?

Thanks!
0
Comment
Question by:BarryTice
  • 4
  • 3
7 Comments
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 6229327
try this

     Dim session As New NotesSession
     Dim db As NotesDatabase
     Dim col As NotesDocumentCollection
     Dim doc As NotesDocument
     Dim item As NotesItem
     
     Set db = session.CurrentDatabase
     Set col = db.UnprocessedDocuments
     Set doc = col.GetFirstDocument()
     NewName = session.GetEnvironmentString("PassedName")
     
     While Not doc Is Nothing
          Set item = doc.GetFirstItem("Programmer")
          oldList = item.Values
         
          If item.text ="" Then
               doc.Programmer = NewName
          Else
               Call item.AppendToTextList(NewName)
               doc.LastEditor = session.UserName
          End If
          call doc.ComputeWithForm(true,false)
          call doc.Save(true,false)
          Set doc = col.GetNextDocument(doc)
     Wend

~Hemanth
0
 
LVL 7

Author Comment

by:BarryTice
ID: 6231259
HemanthaKumar --

That looks like it duplicates the formula I already had, but I don't see anything there to have it conditionally create a record in the second database, which is my real goal. Any ideas?

Thanks!
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 6231439
Yes that exactly duplicates the formula, But

For that I need some more information

Like what field that you have to look for and what criteria and other stuff ,which u will know very well than me.

0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
LVL 7

Author Comment

by:BarryTice
ID: 6231608
In the record in the first database (the one that we just added a programmer name to), there is a field called GUI. If that field is not empty then:
Create a record in the GUI Notification database (on the same server as the first database).
In this new record, set the Owner field to the programmer name we just added to the first document.
Set the Release field in the new record to the Release from the document in the first database.
Set the Component field in the new record to the Component field from the document in the first database.
Set the Project Name field in the new record to the concatenation of the Client and Client ID fields from the document in the first database.
Set the Status field in the new record to 1.
Set the form for the new record to Change.

I can't think of any other information you might need, but then if I knew exactly what I was doing, I wouldn't be asking you! ;)

Please let me know if I missed anything. Thanks!

-- b.r.t.
0
 
LVL 24

Accepted Solution

by:
HemanthaKumar earned 100 total points
ID: 6232013
Dim session As New NotesSession
    Dim db As NotesDatabase
    Dim tdb As NotesDatabase
    Dim col As NotesDocumentCollection
    Dim doc As NotesDocument
    Dim tdoc As NotesDocument
    Dim item As NotesItem
   
    Set db = session.CurrentDatabase
    Set tdb = New NotesDatabase( db.Server, "GUIDB.NSF")
    Set col = db.UnprocessedDocuments
    Set doc = col.GetFirstDocument()
    NewName = session.GetEnvironmentString("PassedName")
   
    While Not doc Is Nothing
         Set item = doc.GetFirstItem("Programmer")
         oldList = item.Values
         
         If item.text ="" Then
              doc.Programmer = NewName
         Else
              Call item.AppendToTextList(NewName)
              doc.LastEditor = session.UserName
         End If
         call doc.ComputeWithForm(true,false)
         call doc.Save(true,false)
         if doc.GUI(0) <> "" then Gosub CreateNewRecord
         Set doc = col.GetNextDocument(doc)
    Wend
Exit sub

CreateNewRecord:
set tdoc = New NotesDocument(tdb)
tdoc.Owner = NewName
tdoc.Release =doc.Release
tdoc.Component = doc.Component
tdoc.Project = doc.Client(0) & doc.ClientID(0)
tdoc.Status = "1"
tdoc.form = "Change"
Call tdoc.Save(true,False)
Return

0
 
LVL 7

Author Comment

by:BarryTice
ID: 6239711
HemanthaKumar --

Thanks!

Sorry for the delay in getting back to this. Notes development is one of those things they let me do when I have slow times in the main part of my job. ("Oh, and why isn't that database done yet?") I didn't get a chance to try this until today.

It works great, though I guess you knew that already. Now all I need to do is write an agent in the GUI database that looks for any records with a flag set to indicate it's been created this way and perform the automatic e-mail that normally happens on document close in that database. But that will be easy.

Thanks again for the help. Enjoy the points!

-- b.r.t.
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 6240071
A typical life of a developer, is meet the deadline and at the sametime support the system, that's the funny part ;-)

Have a good one !

Goodluck
~Hemanth

0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Lotus notes email code 6 116
Migration: Lotus Notes to Exchange 2013 10 329
IBM SAN DS 3512 Controllers Networking issues 11 55
Lotus Notes Calendar Help 6 103
This is an old article, please see an updated version of this article, located here: http://www.experts-exchange.com/articles/23619/Notes-8-5x-Windows-7-Notes-info-and-tips.html
Problem "Can you help me recover my changes?  I double-clicked the attachment, made changes, and then hit Save before closing it.  But when I try to re-open it, my changes are missing!"    Solution This solution opens the Outlook Secure Temp Fold…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question