?
Solved

Script problem, ApeendToTextList not appending

Posted on 2003-02-27
10
Medium Priority
?
412 Views
Last Modified: 2013-12-18
Hello All

I am having a problem with this script. The AppendtoTextList does not append. I have examined this in the debugger. The variables for QAddress show up as do the variables for SendPeople however Qaddress does not appent o SendPeople.

Dim uiws As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Set uidoc = uiws.CurrentDocument
Dim doc As NotesDocument
Set doc = uidoc.Document
Dim FormStatus As String
Dim SendTo As String
Dim QAddress(0 To 2) As Variant
Dim SendPeople As Variant
Dim recipients( 0 To 1 ) As String
Dim ApprName As String
Dim ApprSubmit As String
Dim CoordSubmit As String
Dim strGotoField As String
Dim item As NotesItem
Dim emailDoc As New NotesDocument( db )
Dim rtitem As NotesRichTextItem
Dim DraftSubmit As String
If (doc.FutureDrafters(0) = "Drafting Complete") And (doc.ApprSubmit(0) = "No") Then
'Set some fields on the document
doc.FormStatus = "APP"
doc.ApprSubmit = "Sent"
doc.DocStatus = "Waiting for Drawing Sign-Off"
doc.StatusD = "Drafting Complete"
doc.StatusApp ="In Approval"
doc.DraftFlag = "0"

Set item = doc.GetFirstItem( "SendPeople" )
If item Is Nothing Then
Call doc.ReplaceItemValue ("SendPeople", ApprName)
Else
Call item.AppendtoTextList (ApprName)

End If
SendPeople = doc.GetItemValue("ApprName")
recipients( 0 ) = doc.Coordinator(0)
' recipients( 1 ) = "1720bc@Exchange"
QAddress(0) = doc.QAddress(0)
QAddress(1) = doc.QAddress_1(0)
QAddress(2) = doc.QAddress_2(0)
'E-mail those who need to know
Set emaildoc = New NotesDocument( db )
Set item = doc.GetFirstItem( "SendPeople" )
Call item.AppendToTextList( "QAddress")

doc.SendTo = SendPeople
emailDoc.Form = "Memo"
emailDoc.SendTo = SendPeople
emailDoc.CopyTo = recipients
emailDoc.BlindCopyTo = ""
emailDoc.Subject = doc.PDI_ID(0) & "is waiting for your action. You need to Signoff by pressing the Accept or Deny buttons"

'Create the body field and put in a doclink
'Dim rtitem As NotesRichTextItem
Set rtitem = New NotesRichTextItem(emailDoc, "Body")
Call rtitem.AppendDocLink(doc, "Link to document")
'Compute the computed fields
Call emailDoc.ComputeWithForm(False, False)
'Send the e-mail
Call emailDoc.Send (False)
'Call doc.Save(True, False)
' doc.saveoptions="0"
' Call uidoc.close
End If


TIA

James
0
Comment
Question by:imjamesw
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
10 Comments
 
LVL 7

Expert Comment

by:scottrma
ID: 8035512
Try this instead:

Call item.AppendToTextList(QAddress)

Regards,

Scott
0
 
LVL 7

Expert Comment

by:scottrma
ID: 8035579
Call item.AppendToTextList("QAddress") will append the string literal "QAddress" to the list. Call item.AppendToTextList(QAddress) will append the contents of the QAddress string array.

Regards,

Scott
0
 

Author Comment

by:imjamesw
ID: 8036009
That did not work

I had tried that earlier ,sorry I did not mention it. All I reall want to do is send to Qaddress as well as SendPeople and Recipients. I do not care what method I use

James
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!

 
LVL 7

Expert Comment

by:scottrma
ID: 8036521
Try this:

Set item = emailDoc.GetFirstItem("SendTo")
If Not (item Is Nothing) Then
     Call item.Remove
End If

Dim item As New NotesItem(emailDoc,"SendTo",doc.Coordinator(0))
Call item.AppendToTextList(doc.QAddress(0))
Call item.AppendToTextList(doc.QAddress_1(0))
Call item.AppendToTextList(doc.QAddress_2(0))
Call item.AppendToTextList(doc.ApprName)

Call emailDoc.Send (False)

I think that should be all as far as the addressing logic is concerned. Let me know if that works for you or not.

Regards,

Scott
0
 

Author Comment

by:imjamesw
ID: 8036671
Hi There

I get object variable not set on the Call item.AppendToTextList(doc.QAddress(0))


Thanx
0
 
LVL 7

Expert Comment

by:scottrma
ID: 8037980
Hi James,

I have tried my best to guess at the functionality you are trying to achieve here, I believe I have got it here, but if not, please let me know the specific details of what doesn't work for you. Thanks (entire script follows).

Dim uiws As New NotesUIWorkspace
Dim session As New NotesSession
Dim uidoc As NotesUIDocument
Dim doc As NotesDocument
Dim item As NotesItem
Dim emailDoc As NotesDocument
Dim rtitem As NotesRichTextItem

Set uidoc = uiws.CurrentDocument
Set doc = uidoc.Document
Set db = session.CurrentDatabase

If (doc.FutureDrafters(0) = "Drafting Complete") And (doc.ApprSubmit(0) = "No") Then

     'Set some fields on the document
     doc.FormStatus = "APP"
     doc.ApprSubmit = "Sent"
     doc.DocStatus = "Waiting for Drawing Sign-Off"
     doc.StatusD = "Drafting Complete"
     doc.StatusApp = "In Approval"
     doc.DraftFlag = "0"

     Set item = doc.GetFirstItem("SendPeople")
     If item Is Nothing Then
          Set item = New NotesItem(doc,"SendPeople",doc.ApprName)
     Else
          Call item.AppendtoTextList(doc.ApprName)
     End If
     doc.SendTo = doc.GetItemValue("ApprName")
     'Call doc.Save(True,False)     'Save the document???

     Set emaildoc = New NotesDocument(db)
     Dim item As New NotesItem(emailDoc,"SendTo",doc.Coordinator(0))
     Call item.AppendToTextList(doc.QAddress(0))
     Call item.AppendToTextList(doc.QAddress_1(0))
     Call item.AppendToTextList(doc.QAddress_2(0))
     Call item.AppendToTextList(doc.ApprName)

     emailDoc.Form = "Memo"
     emailDoc.Subject = doc.PDI_ID(0) & "is waiting for your action. You need to Signoff by pressing the Accept or Deny buttons"

     Set rtitem = New NotesRichTextItem(emailDoc,"Body")
     Call rtitem.AppendDocLink(doc,"Link to document")
     Call emailDoc.ComputeWithForm(False,False)
     Call emailDoc.Send(False)

End If

Regards,

Scott
0
 

Author Comment

by:imjamesw
ID: 8041626
Hi Scott

Ireally appreciate your assitance on this.

This is an exiting script that has been working well for sometime, there were some changes made to the form and the QAddress fields were added. All I want to do is to send mail to the people listed in the apprname and the qaddress fields and cc the folks in the recipients.

So the only addition is the Qaddress related script.
I will include the entire script for before the changes.

Sub Querysave(Source As Notesuidocument, Continue As Variant)
'Set the session and db variables
     Dim session As New NotesSession
     Dim db As NotesDatabase
     Set db = session.CurrentDatabase
'Set the front-end workspace and uidoc
     Dim uiws As New NotesUIWorkspace
     Dim uidoc As NotesUIDocument
     Set uidoc = uiws.CurrentDocument
     Dim doc As NotesDocument
     Set doc = uidoc.Document
     Dim FormStatus As String
     Dim SendTo As String
     Dim QAddress As String
     Dim SendPeople As Variant
     Dim recipients( 0 To 1 ) As String
     Dim ApprName As String
     Dim ApprSubmit As String
     Dim CoordSubmit As String
     Dim strGotoField As String
     Dim item As NotesItem
     Dim emailDoc As New NotesDocument( db )
     Dim rtitem As NotesRichTextItem
     Dim DraftSubmit As String
     
     If (doc.FutureReviewers(0) = "Review Complete") And (doc.DraftSubmit(0) = "No") Then
         
'Set some fields on the document
          doc.FormStatus = "DFT"
          doc.DraftSubmit = "Sent"
          doc.StatusRev =  "Complete"
          doc.DocStatus = "Waiting for Team to Create or Revise Product Information"
          doc.StatusD = "In Drafting"
          doc.Assg2LDDate =Today()
         
'E-mail those who need to know
          recipients( 0 ) = doc.Coordinator(0)
          recipients( 1 ) = "1720bc@Exchange"
          emailDoc.CopyTo = recipients
         
          emailDoc.Form = "Memo"
          emailDoc.SendTo = doc.LeadDrafter(0)
          emailDoc.CopyTo = recipients
          emailDoc.BlindCopyTo = ""
          emailDoc.Subject = doc.PDI_ID(0) & "is waiting for your action. You may assign it to a Drafter or do it yourself. Click Submit to Assigned Drafter or Drafting Complete button accordingly."
'Create the body field and put in a doclink
          Set rtitem = New NotesRichTextItem(emailDoc, "Body")
          Call rtitem.AppendDocLink(doc, "Link to document")
'Add a sunshine view icon :-)
          emailDoc.~_ViewIcon = 148
'Compute the computed fields
          Call emailDoc.ComputeWithForm(False, False)
'Send the e-mail
          Call emailDoc.Send (False)
         
     End If
     
     
     
     'Send to Approvers and change Status
    ' Stop  
     If (doc.FutureDrafters(0) = "Drafting Complete") And (doc.ApprSubmit(0) = "No") Then
'Set some fields on the document
          doc.FormStatus = "APP"
          doc.ApprSubmit = "Sent"
          doc.DocStatus = "Waiting for Drawing Sign-Off"
          doc.StatusD = "Drafting Complete"
          doc.StatusApp ="In Approval"
          doc.DraftFlag = "0"
         
          SendPeople = doc.GetItemValue("ApprName")
          recipients( 0 ) = doc.Coordinator(0)
          recipients( 1 ) = "1720bc@Exchange"
'E-mail those who need to know
          Set emaildoc = New NotesDocument( db )    
          Set item = doc.GetFirstItem( "SendPeople" )
         
         
          doc.SendTo = SendPeople
          emailDoc.Form = "Memo"
          emailDoc.SendTo = SendPeople
          emailDoc.CopyTo = recipients
          emailDoc.BlindCopyTo = ""
          emailDoc.Subject = doc.PDI_ID(0) & "is waiting for your action. You need to Signoff by pressing the Accept or Deny buttons"
         
'Create the body field and put in a doclink
          'Dim rtitem As NotesRichTextItem
          Set rtitem = New NotesRichTextItem(emailDoc, "Body")
          Call rtitem.AppendDocLink(doc, "Link to document")
'Compute the computed fields
          Call emailDoc.ComputeWithForm(False, False)
'Send the e-mail
          Call emailDoc.Send (False)
         
     End If
     
      'Send to Approvers and change Status
     If (doc.FutureApprover(0) = "Approval Complete") And (doc.CoordSubmit(0) = "No") Then
'Set some fields on the document
          doc.FormStatus = "RAP"
          doc.CoordSubmit = "Sent"
          doc.DocStatus = "Waiting for Coordinator"
          doc.StatusApp = "Approval Complete"
          doc.ACoorDate1= Date
'E-mail those who need to know
          emailDoc.Form = "Memo"
          emailDoc.SendTo = doc.Coordinator(0)
          emailDoc.CopyTo = doc.RequesterName(0)
          emailDoc.BlindCopyTo = ""
          emailDoc.Subject = doc.PDI_ID(0) & "is waiting for your action. Approval is complete"
'Create the body field and put in a doclink
          Set rtitem = New NotesRichTextItem(emailDoc, "Body")
          Call rtitem.AppendDocLink(doc, "Link to document")
'Compute the computed fields
          Call emailDoc.ComputeWithForm(False, False)
'Send the e-mail
          Call emailDoc.Send (False)
         
     End If
     
     
     
     
End Sub

0
 
LVL 7

Expert Comment

by:scottrma
ID: 8044018
Hi James,

Got your email. Could you send me the whole form that contains this code, copied and pasted into a blank database. That would be helpful as it would allow me to see what fields are multi-value and which are not, etc. Thanks.

Regards,

Scott
0
 
LVL 7

Accepted Solution

by:
scottrma earned 600 total points
ID: 8074119
Hi James,

I have reviewed your code and I believe the problem is related to timing, don't want to go into too much detail, but you make a call such as Call item.AppendToTextList and this is executed but the back end document has not been saved yet so that when you next do a emailDoc.SendTo = SendPeople, you are getting the info currently in memory which does not include your recent AppendToTextList items.

Here is a modified version which I have tested and believe will do what you want. Basically, it builds a dynamic array of strings called SendPeople() and increases the array size by 1 each time we want to add another member.

     If (doc.FutureDrafters(0) = "Drafting Complete") And (doc.ApprSubmit(0) = "No") Then
          doc.FormStatus = "APP"
          doc.ApprSubmit = "Sent"
          doc.DocStatus = "Waiting for Drawing Sign-Off"
          doc.StatusD = "Drafting Complete"
          doc.StatusApp ="In Approval"
          doc.DraftFlag = "0"

          Dim SendPeople() As String
          Dim i As Integer
          Dim TempItem As NotesItem

          Set TempItem = doc.GetFirstItem("ApprName")
          i = 0
          Forall value In TempItem.Values
               Redim Preserve SendPeople(0 To i) As String
               SendPeople(i) = value
               i = i + 1
          End Forall
         
          recipients( 0 ) = doc.Coordinator(0)
          doc.SendTo = SendPeople
         
          Redim Preserve SendPeople(0 To i) As String
          SendPeople(i) = doc.QAddress(0)
          Redim Preserve SendPeople(0 To (i + 1)) As String
          SendPeople(i + 1) = doc.QAddress_1(0)
          Redim Preserve SendPeople(0 To (i + 2)) As String
          SendPeople(i + 2) = doc.QAddress_2(0)
         
          Set emaildoc = New NotesDocument(db)    
          Set item = doc.GetFirstItem("SendPeople")
         
          Call item.AppendToTextList(SendPeople(i))
          Call item.AppendToTextList(SendPeople(i + 1))
          Call item.AppendToTextList(SendPeople(i + 2))
         
          emailDoc.Form = "Memo"
          emailDoc.SendTo = SendPeople
          emailDoc.CopyTo = recipients
          emailDoc.BlindCopyTo = ""
          emailDoc.Subject = doc.PDI_ID(0) & "is waiting for your action. You need to Signoff by pressing the Accept or Deny buttons"
          Set rtitem = New NotesRichTextItem(emailDoc, "Body")
          Call rtitem.AppendDocLink(doc, "Link to document")
          Call emailDoc.ComputeWithForm(False, False)
          Call emailDoc.Send (False)
     End If

I have a modified (and simplified) version of your PDI2c form, which uses this code above, and it seems to work as you want it to. Let me know if you want this as well, I can send it to you.

Regards,

Scott
0
 

Author Comment

by:imjamesw
ID: 8085678
Great Scott
Above and beyond with all your help

Thanx Again

JamesE Wood
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

For users on the Lotus Notes 8 Standard client, this article provides information on checking the Java Heap size and adjusting it to half of your system RAM in attempt to get the Lotus Notes 8.x Standard client to run faster.  I've had to exercise t…
Sometimes clients can lose connectivity with the Lotus Notes Domino Server, but there's not always an obvious answer as to why it happens.   Read this article to follow one of the first experiences I had with Lotus Notes on a client's machine, my…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

752 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