Q
Problem solve Get help with specific problems with your technologies, process and projects.

# Making an agent that would randomly select 5% of the docs from a specified view and send them a note

I am looking to design an agent (scheduled or manual) to randomly select 5% of the docs from a specified view and send a note to the Send To field in each doc in the random selection. I would appreciate any help you can give me.
Does it need to be exactly 5%, or do you just want a 1 in 20 chance of sending a message for each document there, which will give you roughly 5%, but maybe more or less?

The reason I ask is that the latter is much simpler; you can write an agent that runs on all documents:

SELECT @Random < 0.05 & (selection formula from the view);
@MailSend(SendTo; ""; ""; "subject line"; "message body"; ""; [IncludeDocLink])
If you need to send to exactly 5% of the entries, then you probably have to write it in LotusScript -- read the view, repeatedly select a document at random, send to them and remember which documents you already did to prevent doing the same one twice. For example:
Dim ses As New NotesSession
Dim view As NotesView
Dim db As NotesDatabase
Set db = ses.CurrentDatabase
Set view = db.GetView("(\$Inbox)")
Dim entries As NotesViewEntryCollection, anEntry As NotesViewEntry
Dim count As Long, remaining As Long, pos As Long
Dim noteid As String
Dim doc As NotesDocument

Set entries = view.AllEntries
count = entries.Count
remaining = count/20 ' 5% of entries in the view.
Print "count = " & count & ", remaining = " & remaining
While remaining > 0
remaining = remaining - 1
pos = Rnd() * count + 1
Set anEntry = entries.GetNthEntry(pos)
' as long as we already processed this document, choose a different document.
pos = Rnd() * count + 1
Set anEntry = entries.GetNthEntry(pos)
Wend
alreadysent(anEntry.NoteID) = 0 ' don't do this document again.
Set doc = db.GetDocumentByID(anEntry.NoteID)
SendNotice doc
Wend

The SendNotice function is the one that would actually send your e-mail -- you can see how to do this in the examples of the Send method.

#### Start the conversation

Send me notifications when other members comment.

## SearchWindowsServer

• ### Do you need to make Exchange Online backups?

Microsoft has several protective measures in place to let customers restore deleted mail in Office 365, but backup vendors will ...

• ### Updated Exchange Online PowerShell module adds reliability, speed

Microsoft assists Exchange Online administrators who rely on PowerShell by reworking the underlying functionality of several ...

• ### Mammoth March Patch Tuesday lands on Windows admins

Microsoft delivers corrections for 115 unique vulnerabilities, including 26 bugs rated critical in one of its largest Patch ...

## Search400

• ### iSeries tutorials

Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

• ### V6R1 upgrade planning checklist

When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

• ### Connecting multiple iSeries systems through DDM

Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

## SearchDataCenter

• ### Tech giants aim supercomputers, clouds at finding a COVID-19 cure

The new COVID-19 HPC consortium comprised of tech giants, national labs and academia are using supercomputers and clouds to speed...

• ### Top vendor SDDC certification programs for admins

If you decide to grow your knowledge of software-defined data center technologies, VMware, Nuage Networks and Microsoft offer ...

• ### Build up your knowledge of leaf-spine network technology

As organizations deal with challenges of single tree path networks, many admins are considering leaf-spine architectures. Learn ...

## SearchContentManagement

• ### Vendors offer free remote work technology for telecommuting

It's more than a marketing ploy: Cloud technology vendors, seeing their own issues enabling remote work, extend paid products to ...

• ### How businesses should deal with enterprise search issues

Enterprise search issues frequently complicate user experience with ECM systems. While users may face many problems, they also ...

• ### Box, Dropbox shore up clouds; Box-Microsoft integrations go live

Online document collaboration platforms Box and Dropbox shore up cloud bandwidth, security and customer support as remote work ...

Close