LotusScript equivalent: @Unique(@DbColumn

I have a pair of agents now that I use to update one field in a collection of selected documents from a view. Both are done in @Formulae.

The first agent is set as Run Once. It prompts the user for the new value for the field. It writes the value to an environment variable, and then calls the other agent.

The second agent runs on all selected records. It reads the environment variable, makes some comparisons with existing data in each record, and updates (or not) accordingly. Under some circumstances it also sends a mail notification to a list of people that it derives from an @DBColumn.

All this works well, but now I need to add something else. I need it to (under some circumstances) open a new record in a different database for the user to complete. If there are five documents selected in the view and three of these documents match the circumstances, I need for it to create three new records in the other database for the user to fill in the blanks (with some information inheriting over from the source document).

The trouble is that requires an @Command, and you can't use those in an agent that runs on selected documents.

So I need to convert the second agent to LotusScript, I presume. The trouble is, while I do fine at reading LotusScript, I don't know the classes well enough to be quick with coding it.

I've got the script working on the selected documents and performing all the necessary updates without any problem. But I can't figure out how to extract the mailing list.

The current mailing list comes from
   @Unique(@DbColumn("Notes": ""; ""; "(GUIStaff)"; 1))

How do I get this in LotusScript?

After I get the list, I think I've figured out doc.Send() well enough to handle the mailing.

But then I still have the challenge of opening new records in the other database. This needs to open a new record for each document that matches the right conditions and leave it open for the user to complete. Optimally, it would be something like this:

If rightConditions = 1 Then
    Evaluate("@Command([Compose]; @Subset(@DbName; 1): "OtherDB.NSF"; "FormName")")
End If

But you can't evaluate @Commands. So how can I do these things?

Thanks for any help -- b.r.t.

p.s. zvonko -- If this question looks familiar, it's because I had a similar one the other day. But I figured out how to do parts of it, so I deleted the question, which still showed no answers. Later I got a notification that you had responded to the first post, apparently at the same time I deleted it. I've not been able to read your post on that question. Sorry!
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

HemanthaKumarConnect With a Mentor Commented:
For getting the column values, you have to loop through the documents in view like this, there is no equivalent method as dbcolumn, but this block is a variant to it.

'Set the value of db
Set view = db.GetView("(GUIStaff)")
set doc = view.GetFirstDocument
Count = 0
while not doc is nothing
Redim preserve strArr(count) as String
strArr(count) = doc.Sender(0) ' Value representing the I column in the view
set doc = view.GetNextDocument(doc)
count = count + 1
' strArr would store the values of sender

to Compose Document, there is an equivalent script method in notesuiworkspace

ComposeDocument method  

Using a database and form you specify, creates a new document and displays it on the workspace.
Defined in
Set notesUIDocument = notesUIWorkspace.ComposeDocument( [ server$ [, file$ [, form$ [, windowWidth# [, windowHeight#  ]]]]] )
String. Optional. The name of the server where the database resides. If this parameter is omitted or is an empty string (""), the database is opened on the local computer. If both server$ and file$ are omitted or empty strings, the current database is used.
String. Optional. The file name of the database you want to compose a document in. If this parameter is omitted or is an empty string (""), a document is composed in the current database.
String. Optional. The name of the form you want to use to compose the document. If this parameter is omitted or is an empty string (""), the Create Other dialog box is displayed and the user can select a form name.

Double. Optional. The width in inches of the document window. If this parameter is omitted, the window is the width of the current window.
Double. Optional. The height in inches of the document window. If this parameter is omitted, the window is the height of the current window.
Return value
The document that was just created and opened.

BarryTiceAuthor Commented:
HemanthaKumar --

Where you have:
    strArr(count) = doc.Sender(0) ' Value representing the I column in the view

If the field in the document allows multiple entries, would it be appropriate to use
    strArr(count) = doc.Sender

Thanks. --- b.r.t.
BarryTiceAuthor Commented:
Also, if the field allows multiple entries and the view is set to show multiple values as separate entries, will the document be selected more than once as it steps through the view? And how do you handle the @Unique() part, short of sorting the resulting array and stepping through to eliminate the duplicates?

-- b.r.t.
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

I have modified the script based on your comments, This would ensure uniqueness and multivalue in the field "Sender"

     'Set the value of db
     Set view = db.GetView("(GUIStaff)")
     Set doc = view.GetFirstDocument
     Count = 0
     While Not doc Is Nothing
          Forall vals In doc.Sender
               Redim Preserve strArr(count) As String
               IsInArray = Arraygetindex( strArr, vals, 5 )
               If IsInArray = Null Then
                    strArr(count) = vals
                    count = count + 1
               End If              
          End Forall          
          Set doc = view.GetNextDocument(doc)          
zvonkoConnect With a Mentor Commented:
Hello Barry,

it is important to know which Notes version this has to work.
If all users use R5, then you can use nice new R5 features for this unique request...

And for this deleted question; never mind: you got no code (I got no points :-)


Hello Barry,

do you have interest in this new R5 feature?

Hello Barry...
BarryTiceAuthor Commented:
Sorry, guys. This seems to have fallen off my radar last year. Notes development is something I'm "allowed" to do in my spare time at work, but it's not part of my official job description. (Of course, they don't have any other Notes developers.) Anyway, It's not uncommon for me to start on a project and get pulled off to work on something else. That happened here.

Anyway, thanks for your help!

-- b.r.t.
All Courses

From novice to tech pro — start learning today.