Solved

Script: Conditionally create populated doc in another database

Posted on 2001-06-26
7
206 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
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 
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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to access Names.nsf DB from a C# application 14 1,536
Lotus notes forward mail problem 5 404
Work Space in Lotus Notes cannot found 6 170
Domino Lotus Notes Client 4 71
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
Lack of Storage capacity is a common problem that exists in every field of life. Here we are taking the case of Lotus Notes Emails, as we all know that we are totally depend on e-communication i.e. Emails. This article is fully dedicated to resolvin…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

831 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