Solved

Script: Conditionally create populated doc in another database

Posted on 2001-06-26
7
210 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
[X]
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
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I thought it will be a good idea to make a post as it will help in case someone else faces these issues. I trust this gives an idea how each entry in Notes.ini can mean a lot for the Domino Server to be functioning properly. This article discusses t…
Notes Document Link used by IBM Notes is a link file which aids in the sharing of links to documents in email and webpages. The posts describe the importance and steps to create a Lotus Notes NDL file in brief.
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

688 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