Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

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

Getting values from a document in LotusScript

This is something I have needed to learn for sometime!  I need to learn how to get field values off the document

Example the script below - I need to get values off the document and in to the script - as my SendTo (NagList)

Sub Initialize
      Dim s As New NotesSession
      Dim db As NotesDatabase
      Dim mail As Notesdocument
      Dim body As NotesRichTextItem
      Dim doc As NotesDocument
      
      Set db = s.CurrentDatabase
      Set mail = db.Createdocument
      Set body = New NotesRichTextItem(mail, "Body")
      
      mail.Form = "Memo"
      mail.Subject = "A simple message"
Dont work<---->      mail.SendTo = doc.NagList
      mail.ReplyTo = "email@server.com"
      Call body.AppendText("Your application has been:")
      Call body.AddnewLine(2)
      Call body.AppendText("APPROVED")
      Call body.AddNewLine(1)
Dont work<---->      Call body.AppendDocLink(doc.parentDatabase,{' Document '} & doc.Subject(0) & {' in database '} & doc.parentDatabase.Title & {'})
      
      mail.Send(False)
End Sub      

I am not sure what parameters I have to set up in order to retrieve values.

I added -->Dim doc As NotesDocument
but I think there is more
0
Jaziar
Asked:
Jaziar
  • 5
  • 4
1 Solution
 
p_parthaCommented:
Is this the selected document or document coming from a view

YOu can try this for selected document:

  Dim doc As NotesDocument
   
set doccoll = db.unprocesseddocuments
set doc = doccoll.getfirstdocument

0
 
JaziarAuthor Commented:
It will be coming from a view
0
 
p_parthaCommented:
then you have to set the view and loop thru each document:
Set db = s.CurrentDatabase
set view = db.getview(<YOUR VIEWNAME>)
set doc = view.getfirstdocument
while not doc is nothing
     Set mail = db.Createdocument
     Set body = New NotesRichTextItem(mail, "Body")
     
     mail.Form = "Memo"
     mail.Subject = "A simple message"
Dont work<---->     mail.SendTo = doc.NagList
     mail.ReplyTo = "email@server.com"
     Call body.AppendText("Your application has been:")
     Call body.AddnewLine(2)
     Call body.AppendText("APPROVED")
     Call body.AddNewLine(1)
Dont work<---->     Call body.AppendDocLink(doc.parentDatabase,{' Document '} & doc.Subject(0) & {' in database '} & doc.parentDatabase.Title & {'})
     
     mail.Send(False)
set doc = view.getnextdocument(doc)
wend
End Sub    
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
JaziarAuthor Commented:
set doc = view.getfirstdocument = Object varaible not set
0
 
JaziarAuthor Commented:
Sub Initialize
      Dim s As New NotesSession      
      Dim doc As NotesDocument      
      Set db = s.CurrentDatabase
      Set view = db.getview("(NagView)")
      Set doc = view.getfirstdocument
      While Not doc Is Nothing
            Set mail = db.Createdocument
            Set body = New NotesRichTextItem(mail, "Body")
            
            mail.Form = "Memo"
            mail.Subject = "A simple message"
            mail.SendTo = doc.NagList
            mail.ReplyTo = "email@server.com"
            Call body.AppendText("Your application has been:")
            Call body.AddnewLine(2)
            Call body.AppendText("APPROVED")
            Call body.AddNewLine(1)
            Call body.AppendDocLink(doc.parentDatabase,{' Document '} & doc.Subject(0) & {' in database '} & doc.parentDatabase.Title & {'})
            
            mail.Send(False)
            Set doc = view.getnextdocument(doc)
      Wend
      
End Sub      
0
 
p_parthaCommented:
what's your viewname, you have to set that Jaziar...

Partha
0
 
JaziarAuthor Commented:
Set view = db.getview("(NagView)")  is this wrong?
0
 
p_parthaCommented:
Try removing the brackets or check whether the view is spelled properly

partha
0
 
JaziarAuthor Commented:
You are correct the brackets where throwing it off - it is working now

Thanks P_Partha
0

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now