?
Solved

Script: Conditionally create populated doc in another database

Posted on 2001-06-26
7
Medium Priority
?
211 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
Independent Software Vendors: 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 400 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

For Desktop Techs: How to retain a user's Notes configuration data when swapping out the end user's computer. (Assuming that you are not upgrading to a completely different version of Notes client) All you need to do is: 1) install Notes o…
For beginners of Lotus Notes user this is important to know about the types of files and their location supported by IBM Notes. Mostly users are unaware about how many file types are created and what their usages are. This Article is fully dedicated…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

771 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