• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 415
  • Last Modified:

Script problem, ApeendToTextList not appending

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
imjamesw
Asked:
imjamesw
  • 6
  • 4
1 Solution
 
scottrmaCommented:
Try this instead:

Call item.AppendToTextList(QAddress)

Regards,

Scott
0
 
scottrmaCommented:
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
 
imjameswAuthor Commented:
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
Technology Partners: 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!

 
scottrmaCommented:
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
 
imjameswAuthor Commented:
Hi There

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


Thanx
0
 
scottrmaCommented:
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
 
imjameswAuthor Commented:
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
 
scottrmaCommented:
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
 
scottrmaCommented:
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
 
imjameswAuthor Commented:
Great Scott
Above and beyond with all your help

Thanx Again

JamesE Wood
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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