Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2370
  • Last Modified:

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!
0
BarryTice
Asked:
BarryTice
  • 3
  • 3
  • 2
2 Solutions
 
HemanthaKumarCommented:
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
Wend
' strArr would store the values of sender

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

Syntax
=======================
ComposeDocument method  

Example
Using a database and form you specify, creates a new document and displays it on the workspace.
Defined in
NotesUIWorkspace
Syntax
Set notesUIDocument = notesUIWorkspace.ComposeDocument( [ server$ [, file$ [, form$ [, windowWidth# [, windowHeight#  ]]]]] )
Parameters
server$
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.
file$
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.
form$
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.

windowWidth#
Double. Optional. The width in inches of the document window. If this parameter is omitted, the window is the width of the current window.
windowHeight#
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
notesUIDocument
The document that was just created and opened.
=======================

~Hemanth
0
 
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
instead?

Thanks. --- b.r.t.
0
 
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.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
HemanthaKumarCommented:
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)          
     Wend    
0
 
zvonkoCommented:
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 :-)

<|;-)

0
 
zvonkoCommented:
Hello Barry,

do you have interest in this new R5 feature?

0
 
zvonkoCommented:
Hello Barry...
0
 
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.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 3
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now