Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can I move an action from a form to a view?

Status
Not open for further replies.

plc001

Technical User
Dec 23, 2002
15
US
Wanted to move this action from a form to a view, but I'm getting a variable not set error? All I want to do is be able to run the action to multiple docs. Can it be done?


Sub Click(Source As Button)
Dim ws As New notesuiworkspace
Dim session As New notessession
Dim db As notesdatabase
Dim uidoc As notesuidocument
Dim doc As notesdocument
Dim cd As String

Set uidoc = ws.currentdocument
Set doc = uidoc.document

Set maildoc = session.CurrentDatabase.CreateDocument

With maildoc
.Form = "Form name"
.SendTo = "Send to"
.CopyTo = "copy to"
.Subject = "Subject"
.ComputeWithForm False, False
.Send True
End With

Call uidoc.save
Call uidoc.close

End Sub
 
For the view you need to put the code in an agent set to run manually on all selected documents.

In the view, you then create an action that simply runs the agent.

Pascal.


I've got nothing to hide, and I'd very much like to keep that away from prying eyes.
 
Thank you Pascal,

Let me see if I understood you correctly:

1. Put the code above in an agent to run on selected docs.
2. Create a Simple action that runs the agent created in step 1.

Do I need to alter the code in the agent? The action seems to be doing nothing.
All I need is a way to send an e-mail to all docs in the view. By the way, I got it to work in Formula (plain text) but I need to send rich text with attachedments that is why I want to send a form. LotusScript is just out of my league.

Thanks again.
 
Yes, your agent will need to reference unprocessed documents.

Generally you do that like this :
Code:
Dim session as new Notessession
Dim db as notesdatabase
dim coll as NotesDocumentCollection

Set db = session.currentdatabase
Set coll = db.unprocesseddocuments

That way you have a collection of selected documents and you can then iterate through the collection.

Pascal.


I've got nothing to hide, and I'd very much like to keep that away from prying eyes.
 
Also, you'll have to take out the uidoc references - within the form, you're using that to define the current document...and of course, there isn't a current document when you run the agent from the view.

I don't know if you already did this, but try running the action from the view with 'Debug LotusScript' switched on (toggle under File-Tools-Debug LotusScript)...that way, you can work out which variable it is that isn't getting set.

 
I made some changes but still no luck:

Sub Click(Source As Button)
Dim session As New Notessession
Dim db As notesdatabase
Dim coll As NotesDocumentCollection

Set db = session.currentdatabase
Set coll = db.unprocesseddocuments

Set maildoc = session.CurrentDatabase.CreateDocument

With maildoc
.Form = "SafeGuard"
.SendTo = Doc.UserName(0)
.CopyTo = "Jonh Doe"
.Subject = Subject Goes Here"
.ComputeWithForm False, False
.Send True
End With

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top