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(thisD oc.SourceD ocument(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(newDo c, True)
varNewTo = ws.PickListStrings(PICKLIS T_NAMES, True)
Set item= newDoc.GetFirstItem("DocRe aders")
Call item.AppendToTextList(varN ewTo)
item.isreaders = True
k = Inputbox("Enter your comments")
Set item = newDoc.GetFirstItem("SendT o")
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(thisD oc.SourceD ocument(0) )
Set rtItem = thisDoc.GetFirstItem("Comm ents")
strToName = StringReplace(item.Text, "CN=", "")
strToName = StringReplace(strToName, "/OU=Lex/O=Lexmark", "")
Call rtItem.AppendText("Forward ed to " & strToName & " by " & session.CommonUserName)
Call rtItem.AddNewLine(1)
Call rtitem.appendtext("Forward ed Comment: " & k)
Call rtItem.AddNewLine(1)
Call pDoc.Save(True, False)
Call uiDoc.Close(True)
End Sub
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(thisD
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(newDo
varNewTo = ws.PickListStrings(PICKLIS
Set item= newDoc.GetFirstItem("DocRe
Call item.AppendToTextList(varN
item.isreaders = True
k = Inputbox("Enter your comments")
Set item = newDoc.GetFirstItem("SendT
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(thisD
Set rtItem = thisDoc.GetFirstItem("Comm
strToName = StringReplace(item.Text, "CN=", "")
strToName = StringReplace(strToName, "/OU=Lex/O=Lexmark", "")
Call rtItem.AppendText("Forward
Call rtItem.AddNewLine(1)
Call rtitem.appendtext("Forward
Call rtItem.AddNewLine(1)
Call pDoc.Save(True, False)
Call uiDoc.Close(True)
End Sub
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
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
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
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.AppendTe xt( 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.
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.AppendTe
It's not very elegant, but it should get the job done. Otherwise you will need to use Lotus Script.
Set pDoc = db.GetDocumentByUNID(thisD