?
Solved

Help With A Forward Action

Posted on 2005-05-17
6
Medium Priority
?
463 Views
Last Modified: 2013-12-18
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
0
Comment
Question by:Jaziar
  • 3
  • 3
6 Comments
 
LVL 1

Expert Comment

by:gavanhorton
ID: 14019296
I would try replacing the problem line with the following...

Set pDoc = db.GetDocumentByUNID(thisDoc.UniversalID)
0
 

Author Comment

by:Jaziar
ID: 14019453
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
0
 
LVL 1

Accepted Solution

by:
gavanhorton earned 1000 total points
ID: 14020014
Is there any reason you need to use Script ?, If not try doing it with a formula...

1. Create a dialog form with a field called msgtext. Call the form [messagetext].

2. Replace your script action with the following formula
FIELD msgtext:="";
FIELD sendto:=@PickList([Name]);
@DialogBox("[messagetext]";[AutoVertFit]:[AutoHorzFit];"Message Text");
@MailSend(sendto;null;null;"Forwarded by " + @Name([CN];@V3UserName) + " at " + @Text(@Today) + " " + @Text(@Time(@Now)) ;msgtext;" Please Review the following --->";[IncludeDoclink])

If you need to add a comment to a rich text field then you will have problems with formulas. Normally I have a rich text field and then a standard text field called DocumentHistory in each document.

You can update your history with
FIELD DocumentHistory := DocumentHistory + @Char(13) + "Forwarded by " + @Name([CN];@V3UserName) + " at " + @Text(@Today) + " " + @Text(@Time(@Now))
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!

 

Author Comment

by:Jaziar
ID: 14020576
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
0
 

Author Comment

by:Jaziar
ID: 14020763
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?
0
 
LVL 1

Expert Comment

by:gavanhorton
ID: 14024829
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.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

For Desktop Techs: How to retain a user's Notes configuration data when swapping out the end user's computer. (Assuming that you are not upgrading to a completely different version of Notes client) All you need to do is: 1) install Notes o…
Problem "Can you help me recover my changes?  I double-clicked the attachment, made changes, and then hit Save before closing it.  But when I try to re-open it, my changes are missing!"    Solution This solution opens the Outlook Secure Temp Fold…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Loops Section Overview
Suggested Courses

829 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