Solved

Script: Conditionally create populated doc in another database

Posted on 2001-06-26
7
205 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 7

Author Comment

by:BarryTice
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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 Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

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
  In today’s Arena we can’t imagine our lives without Internet as we are highly used to of it. If we consider our life style just for only 2 min we found that face to face communication is swapped by e-communication.  Every Where from Works place to…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

728 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now