Help With A Forward Action

Posted on 2005-05-17
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
Question by:Jaziar
    LVL 1

    Expert Comment

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

    Set pDoc = db.GetDocumentByUNID(thisDoc.UniversalID)

    Author Comment

    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
    LVL 1

    Accepted Solution

    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))

    Author Comment

    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

    Author Comment

    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?
    LVL 1

    Expert Comment


    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.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    This is an old article, please see an updated version of this article, located here:
    For beginners of Lotus Notes user this is important to know about the types of files and their location supported by IBM Notes. Mostly users are unaware about how many file types are created and what their usages are. This Article is fully dedicated…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    779 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

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now