?
Solved

Assigning a value to a field in lotusscript

Posted on 2005-04-25
9
Medium Priority
?
493 Views
Last Modified: 2013-12-18
I need to assign the value from the picklist to the DocReaders field in this script.

Sub Click(Source As Button)
      Dim ws As New NotesUIWorkspace
      Dim db As NotesDatabase
      Dim uiDoc As NotesUIDocument
      Dim thisDoc As NotesDocument
      Dim newDoc As NotesDocument
      Dim varNewTo As Variant
      Dim item As NotesItem
      Dim session As New NotesSession
      Dim view As NotesView
      Dim pDoc As NotesDocument
      Dim strServer As String
      Dim strFilename As String
      Dim rtItem As NotesRichTextItem
      Set uiDoc = ws.CurrentDocument
      Set thisDoc = uiDoc.Document
      Set db = thisDoc.ParentDatabase
      Dim strToName As String
      Set newDoc = New NotesDocument(db)
      Call thisDoc.CopyAllItems(newDoc, True)
      varNewTo = ws.PickListStrings(PICKLIST_NAMES, True)

Somewhere here I need to take the value from varNewTo and append it to the DocReaders Field in the newDoc.

      k = Inputbox("Enter your comments")      
      Set item = newDoc.GetFirstItem("SendTo")
      item.Values = varNewTo
     'newDoc.SenderList = "Forwarded by " & session.CommonUserName & Chr$(13) & newDoc.SenderList(0)
      newDoc.Subject = "Fw: " & thisDoc.Subject(0)    
      newDoc.FowardComments = k      
      Call newDoc.Send(True)
  ' Now, put a note in the original database indicating that the document was forwarded.
      strServer = thisDoc.DatabaseServer(0)
      strFilename = thisDoc.DatabaseName(0)
      
      Set db = New NotesDatabase(strServer, strFilename)
      Set view = db.GetView("2005\Actions")
      Set pDoc = db.GetDocumentByUNID(thisDoc.SourceDocument(0))
      Set rtItem = pDoc.GetFirstItem("Comments")
      strToName = StringReplace(item.Text, "CN=", "")
      strToName = StringReplace(strToName, "/OU=Lex/O=Lexmark", "")
      Call rtItem.AppendText("Forwarded to " & strToName & " by " & session.CommonUserName)
      Call rtItem.AddNewLine(1)
      Call rtitem.appendtext("Forwarded Comment:  " & k)
      Call rtItem.AddNewLine(1)
      Call pDoc.Save(True, False)
      Call uiDoc.Close(True)
End Sub
0
Comment
Question by:Jaziar
  • 4
  • 3
  • 2
9 Comments
 
LVL 46

Accepted Solution

by:
Sjef Bosman earned 200 total points
ID: 13858892
Hope this works:
    Set item= doc.GetFirstItem("DocReaders")
    Call item.AppendToTextList(varNewTo)

0
 

Author Comment

by:Jaziar
ID: 13859020
Error - Variant does not contain an object
- see below to see what I added

Sub Click(Source As Button)
      Dim ws As New NotesUIWorkspace
      Dim db As NotesDatabase
      Dim uiDoc As NotesUIDocument
      Dim thisDoc As NotesDocument
      Dim newDoc As NotesDocument
      Dim varNewTo As Variant
      Dim item As NotesItem
      Dim session As New NotesSession
      Dim view As NotesView
      Dim pDoc As NotesDocument
      Dim strServer As String
      Dim strFilename As String
      Dim rtItem As NotesRichTextItem
      Set uiDoc = ws.CurrentDocument
      Set thisDoc = uiDoc.Document
      Set db = thisDoc.ParentDatabase
      Dim strToName As String
      Set newDoc = New NotesDocument(db)
      Call thisDoc.CopyAllItems(newDoc, True)
      varNewTo = ws.PickListStrings(PICKLIST_NAMES, True)
Added->      Set item= doc.GetFirstItem("DocReaders")
Added->      Call item.AppendToTextList(varNewTo)
      k = Inputbox("Enter your comments")      
      Set item = newDoc.GetFirstItem("SendTo")
      item.Values = varNewTo
     'newDoc.SenderList = "Forwarded by " & session.CommonUserName & Chr$(13) & newDoc.SenderList(0)
      newDoc.Subject = "Fw: " & thisDoc.Subject(0)    
      newDoc.FowardComments = k      
      Call newDoc.Send(True)
  ' Now, put a note in the original database indicating that the document was forwarded.
      strServer = thisDoc.DatabaseServer(0)
      strFilename = thisDoc.DatabaseName(0)
      
      Set db = New NotesDatabase(strServer, strFilename)
      Set view = db.GetView("2005\Actions")
      Set pDoc = db.GetDocumentByUNID(thisDoc.SourceDocument(0))
      Set rtItem = pDoc.GetFirstItem("Comments")
      strToName = StringReplace(item.Text, "CN=", "")
      strToName = StringReplace(strToName, "/OU=Lex/O=Lexmark", "")
      Call rtItem.AppendText("Forwarded to " & strToName & " by " & session.CommonUserName)
      Call rtItem.AddNewLine(1)
      Call rtitem.appendtext("Forwarded Comment:  " & k)
      Call rtItem.AddNewLine(1)
      Call pDoc.Save(True, False)
      Call uiDoc.Close(True)
End Sub
0
 
LVL 14

Assisted Solution

by:p_partha
p_partha earned 200 total points
ID: 13859027
apart from bro's code, just add this to be on the safer side:

item.isreaders = true

Partha
0
Industry Leaders: 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!

 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 13859063
Hi Partha,

That's always good to add.

Sorry Jaziar, another typo, doc should have been newDoc:
    Set item= newDoc.GetFirstItem("DocReaders")
    Call item.AppendToTextList(varNewTo)
   
0
 

Author Comment

by:Jaziar
ID: 13859067
Off topic question
When I am putting in a role as a default value is this correct
"[Everybody]"

Topic
Still getting variant does not contain object
0
 
LVL 14

Expert Comment

by:p_partha
ID: 13859074
what line is the error jaziar, and i believe the way u have put for the role is correct

Partha
0
 

Author Comment

by:Jaziar
ID: 13859079
k
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 13859116
Are you sure that newDoc has a field DocReaders??
0
 

Author Comment

by:Jaziar
ID: 13859236
Its working - Thanks
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is an old article, please see an updated version of this article, located here: http://www.experts-exchange.com/articles/23619/Notes-8-5x-Windows-7-Notes-info-and-tips.html
For beginners of Lotus Notes user this is important to know about the types of files and their location supported by IBM Notes. Mostly users are unaware about how many file types are created and what their usages are. This Article is fully dedicated…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question