Link to home
Start Free TrialLog in
Avatar of Jaziar
Jaziar

asked on

Help With A Forward Action

I have a foward action button on my main form.  When someone gets a doclink from the main form and they come to the document they have a option of fowarding to a new user.

In the script it ask who do we want to send it to and then ask for a comment.

Say Jaziar opens the document and I want Bob to respond to the request - I click foward and it ask who - I put in Bob's name then it ask why - I type "Bob can you look at this and reply"  two things should happen here

1.  Bob should get a email with my comments and a doclink

"Jaziar has foward this to you and here are his comments" (something like this as a message)

2.  At the bottom of the Orig. Document it should append in a rich text Comments field
it should append -

Jaziar has fowarded the request to Bob
FW: Comments: Bob can you look at this and reply

This code I have was working when I was using 3 forms - now I am only using the main form - so there is a lot of code in this I dont think I need.  It stills emails and comments - but does not place anything in the document. This one line is causing a ID error -> Set pDoc = db.GetDocumentByUNID(thisDoc.SourceDocument(0))

Please help me clean up the code.

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
      Dim strToName As String
      
      Set uiDoc = ws.CurrentDocument
      Set thisDoc = uiDoc.Document
      Set db = thisDoc.ParentDatabase
      Set newDoc = New NotesDocument(db)
      Call thisDoc.CopyAllItems(newDoc, True)
      varNewTo = ws.PickListStrings(PICKLIST_NAMES, True)
      Set item= newDoc.GetFirstItem("DocReaders")
      Call item.AppendToTextList(varNewTo)
      item.isreaders = True
      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("All Documents")
      Set pDoc = db.GetDocumentByUNID(thisDoc.SourceDocument(0))
      Set rtItem = thisDoc.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
Avatar of gavanhorton
gavanhorton
Flag of United States of America image

I would try replacing the problem line with the following...

Set pDoc = db.GetDocumentByUNID(thisDoc.UniversalID)
Avatar of Jaziar
Jaziar

ASKER

Yes that fixed that problem but the foward is still sending the form and not a memo form.  So when I try to open up the email I get

Illegal Circluar USE: Discussion Routines

Then it opens the form

I just want it to send a doc link back to the form
ASKER CERTIFIED SOLUTION
Avatar of gavanhorton
gavanhorton
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Jaziar

ASKER

I am trying the formula - but this part is really important

At the bottom of the Orig. Document it should append in a rich text Comments field
it should append -

Jaziar has fowarded the request to Bob
FW: Comments: Bob can you look at this and reply

It is a rich text field named Comments
Avatar of Jaziar

ASKER

You are correct everything worked well except the appending of the text to the document.  Any suggestions on how to write to a rich text field?
Jaziar,

There is no way to write to a rich text field using a formula. What you could do instead is have a hidden text field somewhere in your document. Write to the text field using a formula and then when you save or close the document you can use "Call notesRichTextItem.AppendText( text$ )" to update your rich text item with the comments.

It's not very elegant, but it should get the job done. Otherwise you will need to use Lotus Script.