Link to home
Start Free TrialLog in
Avatar of Jaziar
Jaziar

asked on

Embedding Mail Tool In a Form

I will create a form called Discussion.  This form will be setup like a normal new message form .
all names in [  ] is fields

 text               field
Security         [Security]
Requester      [Requester] <- Autocompletes with the current Users ID
Date              [Date]<-  Also Autocompletes with todays date
TO                [To]<-  Can use address book or defined names in a NameList
CC                [CC] <- Address Book
Subject         [Subject] <-  Going to be a dialog book with predifined topics
Message       [Message]
Attachments  [Attach] <- Rich Text

Store Messages and Replies  [ Comments]

Ok here is the question?

If I open this form and fill out the information.  I put John Smith as the TO: Person and in the message box I put - I need the totally counts.  I then hit send.  The Message is put in the comments field something like this.

From - Jaziar - March 04 2005 ---

I need the totally counts

---------------------------------------

So then John gets the email in his inbox.  He opens the mail and see a reply button.  When he hits the reply button, a form opens that looks like the first one but his name is in the requester and Jaziar is in the TO: field.  The subject is the same as the first.  The message is clear.  He types I have 4 to add.  He then hits send.  This should send a email to JAziar and also place his text in the comments sections.  

Example:

From - Jaziar - March 04 2005 ---

I need the totally counts

---------------------------------------
From - John Smith - March 04 2005 ---

I have 4

---------------------------------------
But I need it to create a child document related to the first parent - so in a view it could look like this

Jaziar  (Subject of email) Counts Needed (Date)  March 04 2005
                                     |>  John Smith Counts Needed March 04 2005

That way you can keep track of the replies but also have all the comments on the first page for quick access.


One problem is the repliers should never even realize that are sending email out of the database and not thier inbox.


Can this be done??  PLease ask questions if this is not clear.

Very Urgent and needed
Avatar of TSO Fong
TSO Fong
Flag of Sweden image

I would certainly be possible to have the message that appears in the user's mailbox include its own Reply button, and have that button create a UIDocument in your database rather than in the original. The button could also, if script rather than @Functions, affect the history fields of the parent document with every update, in addition to making a response document.

So, what you're looking for first is a form where the user types into the Message field, and that message (and any attachments) becomes part of the Comments field, which is a non-editable history that includes the Message data from the response documents?

And, when John Smith replies that he has 4, if you reply to his reply, do you want it as a child of the original request, or a child of John Smith's child?

-- b.r.t.
Avatar of Jaziar
Jaziar

ASKER

That should be a child of the original request.

Example:

There is a view called - Discussion
I click it and hit [Create Discussion] - My form Opens maybe on this form there is a send email button that opens and some of the fields are filled in?  Not sure about this part.  So I add John Smith and Chuck Roast to the TO: Field.  I enter a message - "Please send me your totals for the year".  I hit send.  There should be a field in the form that stores what the subject was and the message a long with the date and who sent it.

John and chuck get the email in thier inbox - opens it and reads "please send me your numbers"  There is a reply button.  John clicks reply and email form opens and he responds I have 5 and sends.  The original form is updated with his message, maybe appended to the original and a child document is created.  Chuck does the same, same thing happens.

So now when you look at the views you will see

Jaziar  March 10, 2005  Subject Topic   <- this is the original
                                  John Smith  March 10, 2005  Subject <-- Reply (child)
                                  Chuck Roast March 10, 2005 Subject <-- Reply (Child)

Jaziar March 11, 2005 Etc Etc


Hope this helps
OK. Would there ever be a response to Chuck's document? Or are there only ever responses to the one you put in?

Will John and Chuck's documents have attachments, too? More importantly, do those attachments need to be included back into the summary of their documents that appears in your document?

For that matter, when they reply and say "I have 5", is there a reason that needs to be in a rich-text field? If it's only going to be text, I don't see what the reason would be (and it make the processing a lot easier if it's not). If Chuck and John's responses need to be rich text in order to include attachments, do the attachments need to be moved into your document as part of that summary, or just the text?

What if Chuck thinks a lot of himself, and instead of putting in "I have 5" he puts in "I have five for today, which is a significant improvement over last Tuesday. In fact, here's the complete statistical analysis of my submissions over the past 16 weeks: ..."

Do you want all of Chuck's ramblings copied over into the summary in your document, or, say, just to the first period after the hundredth letter?

I'm thinking that if Chuck and John get a place to respond, but it's not rich text, this would be an easy thing. It's a little bit more complicated (but far from impossible) if Chuck and John enter their replies in a rich-text field and include attachments.

-- b.r.t.
Avatar of Jaziar

ASKER

There are only responses to the original document.  
Yes all can have a attachements included.  
I would like a field for the attachments (Good Question).  

How about the messages be in a text field and we need to capture all the verbage typed and then having a Rich text field just for the Attachements?

OK. So the attachments do not need to be included in the summary in the "main" document?
Avatar of Jaziar

ASKER

No - but would be nice if they show up on the main document, but right now I dont think they have to.
How about if, instead of including the attachments in the "main" document, the "main" document included a doc link to each of the response documents next to that document's text summary?
Avatar of Jaziar

ASKER

That would be great!

Barry I just ran the Import and It is creating a new document each time I Import it.  I set my Date to Jan and then selected 2005 and import -  Worked - then I changes Date to Feb and import and the logic worked but it creates a new document each time I import.  Yesterday it did not do that.  Does it have anything to do with picking 2005?  I can start a new question if you like.
No, you've spent enough points on this. But I would prefer we move the conversation into the previous (closed) thread, so that if anyone else ever comes across it they'll see this issue, too.

I'll see you there.
Avatar of Jaziar

ASKER

kk
Jaziar --

I have some of my _real_ work I've got to catch up on today, and can't devote a lot of coding time to it during the day. Are you on a tight deadline on this? Or, can I throw some code together after hours tonight?

-- b.r.t.
Avatar of Jaziar

ASKER

You can do it afterhours - Real Work always comes first.  I don't need this until Thursday time frame.

I do appreaicate all your work!!!!!!

You have and continue to do a great job for me.
OK. I'll try to throw together a rough framework. You'll probably need to fill in some of the details, but it shouldn't be too bad.

-- b.r.t.
How critical is it that the forms mimic the appearance of the mail database?

If they get a note in their inbox and they open (as an e-mail), as long as it has a Reply button at the top, and that creates a document that has a Send button at the top (or submit, or whatever), does it matter that the look and feel is a little different from what they get in their own mail database? Otherwise, we're talking about a lot of complexity in loading subforms based on user preferences and such, and it could get pretty complicated.

If you're content to have simple one-button replies handled from their inbox, without them having to explicitly go and open the database and create a document, that shouldn't be too bad.

-- b.r.t.
Avatar of Jaziar

ASKER

you are correct - It does not have to look just like a mail form.  We can create our own form and use it.  I think the key to it is for the user to not have to go to the database and open it up and then reply.

If you're content to have simple one-button replies handled from their inbox, without them having to explicitly go and open the database and create a document, <-  That should be fine
OK, Jaziar. I've come up with a three-form solution for you.

The first form is the one on which the original request is made. In the example above, it's the one created by Jaziar. (That would be you.) We'll call this form "Request". It includes a Send button. It has a SendTo field where you enter the names of the people from whom you're requesting responses. It should have a Subject field, too, which will display in the user's inbox. (It doesn't have to show -- it can be a computed value.) It has a Comments field that is rich-text and computed, with a computed formula of Comments. (It's self-referential.) It has two hidden fields on it: DatabaseServer and DatabaseName. They are computed when composed, and their formulas are: @Subset(@DbName; 1) and @Subset(@DbName; -1), respectively.

The second form is the one on which the outgoing e-mails are created and sent. This is the form that Chuck and John see when they open the message in their inboxes. It includes a Reply button. We'll call this form "Outgoing Request Form". It is defined as saving the form with the document.

The third form is the one on which the responses are composed back in the original database. It is defined as a response document. We'll call this form "Response Form".

The Send button on "Request" has this code:

==== BEGIN PASTE ====
Sub Click(Source As Button)
      Dim ws As New NotesUIWorkspace
      Dim session As New NotesSession
      Dim db As NotesDatabase
      Dim uiDoc As NotesUIDocument
      Dim doc As NotesDocument
      Dim mDoc As NotesDocument
      
      Set uiDoc = ws.CurrentDocument
      Call uiDoc.Save
      
      Set doc = uiDoc.Document
      Set db = session.CurrentDatabase
      Set mDoc = New NotesDocument(db)
      
      Call doc.CopyAllItems(mDoc)
      mDoc.Form = "Outgoing Request Form"
      mDoc.SourceDocument = doc.UniversalID
      Call mDoc.Send(True)
      Call uiDoc.Close(True)
End Sub
===== END PASTE =====
What this does is create a new document to mail, copying all items from the document you (Jaziar) entered in your original request. It then overlays the form with the outgoing form, and sets a "SourceDocument" field in the outgoing document so it can find the original parent document when it needs to. Of course, there's no requirement that the SourceDocument field be visible or even shown on the form in the designer. It's required that the field you have on this form where you enter the names of the people you are making the request of is called "SendTo". (Capitalization doesn't matter, but the name must be that, unless you want to adjust the code accordingly.)

The second form, "Outgoing Request Form", has most of the same fields that show on the original request, but they're read-only (computed when composed, self-referential). After all, this is just a request for information. It has one action button, "Reply", with this code in it:
==== BEGIN PASTE ====
Sub Click(Source As Button)
      Dim session As New NotesSession
      Dim ws As New NotesUIWorkspace
      Dim db As NotesDatabase
      Dim thisUIDoc As NotesUIDocument
      Dim uiDoc As NotesUIDocument
      Dim doc As NotesDocument
      Dim nDoc As NotesDocument
      Dim sDoc As NotesDocument
      Dim strServer As String
      Dim strFilename As String
      
      Set thisUIDoc = ws.CurrentDocument
      Set doc = thisUIDoc.Document
      strServer = doc.DatabaseServer(0)
      strFilename = doc.DatabaseName(0)
      
      Set db = New NotesDatabase(strServer, strFilename)
      If Not(db.IsOpen) Then
            Call db.Open("", "")
      End If
      
      Set sDoc = db.GetDocumentByUNID(doc.SourceDocument(0))
      Set nDoc = New NotesDocument(db)
      Call nDoc.MakeResponse(sDoc)
      nDoc.Subject = doc.Subject(0)
      nDoc.Form = "Response Form"
      nDoc.Creator = session.CommonUserName
      Set uiDoc = ws.EditDocument(True, nDoc)
      Call thisUIDoc.Close(True)
End Sub
===== END PASTE =====
This grabs hold of the originating database, finds the source document that you (Jaziar) originally created (sDoc), creates a new document in the database (nDoc), defines that as a response to the original, casts it onto the Response Form, sets the Creator field (which I had as a field showing on the form), saves it, and then opens it in the user's workspace, closing the e-mail.

The third form, the "Response Form", collects information in the Answer field, according to this code. That's a non-rich-text field. (There can be a separate field for attachments, you said.) It has this as its QuerySave:

==== BEGIN PASTE ====
Sub Querysave(Source As Notesuidocument, Continue As Variant)
      Source.Document.BeenSaved = "1"
End Sub
===== END PASTE =====

This allows the user to cancel the new response without saving, and have it not process. It's checked in the QueryClose.

The QueryClose, then, is:

==== BEGIN PASTE ====
Sub Queryclose(Source As Notesuidocument, Continue As Variant)
      Dim session As New NotesSession
      Dim db As NotesDatabase
      Dim doc As NotesDocument
      Dim pDoc As NotesDocument
      Dim item As NotesItem
      Dim rtItem As NotesRichTextItem
      
      If Not Source.EditMode Then
            Exit Sub
      End If
      
      Set doc = Source.Document
      If doc.BeenSaved(0) >< "1" Then
            Exit Sub
      End If
      
      Set db = session.CurrentDatabase
      Set pDoc = db.GetDocumentByUNID(doc.ParentDocumentUNID)
      
      Set item = pDoc.GetFirstItem("Responses")
      If Not(item.Contains(doc.UniversalID)) Then
            ' This response hasn't been done yet.
            Call item.AppendToTextList(doc.UniversalID)
            Set rtItem = pDoc.GetFirstItem("Comments")
            Call rtItem.AppendDocLink(doc, "Link to " & doc.Creator(0) & "'s Reply")
            Call rtItem.AppendText("   (" & doc.Creator(0) & ")  " & doc.Answer(0))
            Call rtItem.AddNewLine(1)
            Call pDoc.Save(True, False)
      End If
End Sub
===== END PASTE =====
If the document isn't being edited, don't bother. If it hasn't been saved, don't bother.

Get a handle on the original request document, which can be done from this document's ParentDocumentID property. Check to see if this document has already been linked into the parent document, and if not, link it in.

It adds to the Responses field to show this response has been processed. It gets the Comments field in the original, appends in a doc link to itself, appends in the text Chuck Roast added to the Answer field, adds a carriage return to prepare for the next entry, and saves the parent document.

Done.

All the other details, such as setting up the views to display your response hierarchy nicely, and prettying up the forms with the right layout, and putting a "Save and Close" button on the third form.

How does this look to you?

-- b.r.t.
As I look over it now, I see some potential troubles. For example, there will be an error if you create a request, but your request document is deleted before Chuck Roast responds to it. That can be checked for in the QueryClose code above, after the line "Set pDoc = db.GetDocumentByUNID(doc.ParentDocumentUNID)", by saying, If pDoc Is Nothing Then {do something, a messagebox or something, and exit the subroutine} End If.

-- b.r.t.
Avatar of Jaziar

ASKER

wow Barry - Let me finish my current Issue and then I am going to jump on this.  Looks great - Thanks
Avatar of Jaziar

ASKER

OK I am now starting to look over the code and get started on this
Avatar of Jaziar

ASKER

Quick Question I am creating the Request form.

I have placed a field on it for attachments called RequestAttachment.

I have put a image resource there of a paperclip.  I want them to be able to click the image and create attachments starts.  does this make sense?
Avatar of Jaziar

ASKER

Question Barry - I have Request Form done and then copied form and changed the fields save as  Outgoing Request Form.  What fields are in the 3rd form?  Is the 3rd form a copy of the second and first?
Sorry. I'm just now seeing your ? from 2:30 ago.

The third form is, in the example I threw together, called "Response Form". It has whatever fields you need for Chuck Roast and John Smith to fill out in response to your original question. For the code I provided, it must have a Creator field (this is set in the Reply button from the Outgoing Request Form when the document is created, and doesn't have to be visible). More importantly, it must have an Answer form. This is where Chuck and John reply to your question of "How many do you have?" This field is not rich-text, and text from this field is copied into the Comments field on your original Request document, along with a link to the Response Form document.

I believe you also said you wanted an Attachments field in there. You would add that separately as rich text.

Any other fields you want would just depend on your needs. It would be easy enough to copy in the original subject and the name of the person who made the original form. You could do those when the document is created in the Reply button of the second form.

As for the button, have you got that squared away already? I believe you can use @Commands to set focus to the RequestAttachment field (@Command([EditGotoField])) and then have it browse for attachments (@Command([EditInsertFileAttachment])).

-- b.r.t.
Avatar of Jaziar

ASKER

welcome back - I have to first 2 forms done
Avatar of Jaziar

ASKER

form 1

the user creates the message and that form is the parent form.  Hits send

Form 2

this form is the actual email that is sent out and give the user a way to reply and make children forms

Form 3

is the child form with the response information.  can form 3 ever place any information in form 1.

I was kinda looking for a field in form 1 that stores all the messages from the children - is that possible
Yes, those are correct descriptions of these three forms.

Yes, that happens.

The Comments field in Form 1 is rich-text and is calculated, with Comments as the formula. (In my post with the code, I described it as self-referential.)

The Reply button on Form 2 creates the document on Form 3, sets it as a response to the document on Form 1, and leaves it open in edit mode.

The QueryClose in Form 3 looks up its parent document (the one on Form 1) and copies a link to itself and the text from the Answer field into the Comments field of the document on Form 1, using this code:

          Set rtItem = pDoc.GetFirstItem("Comments")
          Call rtItem.AppendDocLink(doc, "Link to " & doc.Creator(0) & "'s Reply")
          Call rtItem.AppendText("   (" & doc.Creator(0) & ")  " & doc.Answer(0))
          Call rtItem.AddNewLine(1)
          Call pDoc.Save(True, False)

(First, get the rich-text item called Comments from the Form-1 document. Append a doc link into that rich-text field to "doc" in this case, which happens to be the Form-3 document on which this QueryClose is running. Append text into that same rich-text field of the Form-3 document's creator and the text entered into the Answer field on the Form-3 document. Add a carriage return so the field will be ready for the next response document's entry. Save the Form-1 document.)

Does that help clear it up?

-- b.r.t.
Avatar of Jaziar

ASKER

Form 1

Comments (same as messages) Ex:  You guys I need 4k to start off!

Send

Form 2

Shows up as?  Does the reply user have to type back in to the comments field or should I have a another field for them to reply to?

I was thinking that form 2 comments would show up computed and the user has a reply field to put his response in.  That response would be added to form 1 comments
Jaziar --

In my sample database, I had that as a field called Message, which was rich-text and editable on Form 1 and rich-text and computed (formula = Message) on Form 2. That didn't, then, appear directly on Form 3 (though it certainly could if you wanted).

The Comments field on Form 1, then, is computed only. It doesn't include your original "You guys I need 4k to start off!" message, but it _does_ include doc links to and the text from everybody's responses.

-- b.r.t.
Also, be forewarned that whatever you have in the "Subject" field on Form 1 will also move into the "Subject" field on Form 2, and therefore will be the subject line seen in the recipients' inboxes.
Avatar of Jaziar

ASKER

Ok I think that will work.  A lot to learn here
The subject is the way I want it.
Avatar of Jaziar

ASKER

Form 1

has Message - where i type
has Comments - gathers replies

Form 2

has Message - Computed to sure what was said
is there a field called Comments so they can reply to the first one
There doesn't need to be a Comments field on Form 2. Remember that Form 2, as far as Chuck Roast is concerned, is read-only. He gets Form 2 in his inbox and clicks a button on it, and that button creates a document on Form 3 back in the original database.

Form 3 has a field that, as coded above, is called Answer. It is **not** rich text, and that's where Chuck types his response to your original question. The text from the Answer field is copied into the Comments field (along with the user's name and a doc link) back on Form 1.

-- b.r.t.
Avatar of Jaziar

ASKER

OK - Form 2 is nothing more than a email form.  I now understand
It's _slightly_ more than an e-mail form, in that it has an action attached that creates Form 3. Other than that, you're right.
Avatar of Jaziar

ASKER

Too many late nights of late.  I may call it the day and start fresh in the morning
That's why, though, you have to have Form 2 defined in this database, and you have to have it save the form with the document, and why the line:
Call mDoc.Send(True)
has True instead of False as the parameter. (That's the parameter that tells it to send the form with it.)

Otherwise, the document that Chuck reads in his inbox won't have the correct Reply action attached because it will just appear on the default mail form instead.

-- b.r.t.
Avatar of Jaziar

ASKER

Do I need a save button or anything in Form 3 - How does it know to close
Yes, you'll need some kind of Save/Close button. (Or, your users will have to be smart enough to hit <Ctrl-S> and <Esc>, but in my experience, that's asking way too much from them.)

The save/close button can be simple. They don't require any code outside of what you'd use somewhere else:

@Command([FileSave]);
@PostedCommand([FileCloseWindow])

should do it.

-- b.r.t.
Avatar of Jaziar

ASKER

Also in form 3 I would like to have some fields on there from form1 as a refernce.

RequestSecurity
RequestRequester
RequestDate
Message

That way as the user is replying they can refernce the data
Avatar of Jaziar

ASKER

Getting The Error when I save Form 3  "Invalid univseral ID"
Yes, that's easy.

Remember that all the fields on Form 1 were copied over to Form 2 when we did the
Call doc.CopyAllItems(mDoc)

Therefore, all that data is available in the document that appears in Chuck's mailbox, even if you don't display it. (Remember that a Notes document is a collection of fields, and not all those fields have to be displayed on a form used to look at the document.)

Therefore, when the Reply action on Form 2 creates the reply document on Form 3, you can go ahead and populate whatever fields you like from it.

Consider that the code above looks like this:
     Set nDoc = New NotesDocument(db)
     Call nDoc.MakeResponse(sDoc)
     nDoc.Subject = doc.Subject(0)
     nDoc.Form = "Response Form"
     nDoc.Creator = session.CommonUserName

in this case, nDoc is the new document (the response document, on "Response Form" or Form 3, as we're calling it). doc is the document on Form 2 from which this script is running. We're putting the Subject from that document into the Subject field on the new document. The Subject on Form 2 was populated from the CopyAllItems mentioned above, from the Send button on Form 1. In this same way, you could put any information from Form 1 (and therefore also stored in the Form 2 document) into any field you like on Form 3. For example, you could use:
nDoc.RequestRequester = doc.Requester(0)

if you have a field on Form 1 called Requester. (The field on Form 3 doesn't have to have the same name as it did on Forms 1 and 2.)

The (0) subscript on the end is because Notes treats all fields like arrays, even if they only have one element. Putting a zero there tells it to get the zero-index (first) element from the field's Values array.

-- b.r.t.
Can you put it in debug mode and see where the error is coming from?
Avatar of Jaziar

ASKER

Yea I will in the morning - I am so tired right now
I know the feeling...
Avatar of Jaziar

ASKER

Started the debugger and nad tried the forms.  The Debugger never found the error.  The Send script worked the Reply Script worked - then as I entered information on the form 3 and hit save - thats when I got the error-  So I am guessing it is in the Queryclose
When you hit save, I presume that's a button that saves and closes? If there is no "close" built into your "save," the QueryClose won't be running.

In any case, it certainly makes sense that the program would be stopping with that error on this line:

     Set pDoc = db.GetDocumentByUNID(doc.ParentDocumentUNID)

Do this, please:
Put the command Stop in at the beginning of the QueryClose. That will force the debugger to stop there (assuming the debugger is working correctly, which is not guaranteed). From there, you can use <F8> to step through the code line by line until the error occurs. This will let you verify the line that gets the error.

-- b.r.t.
Avatar of Jaziar

ASKER

I put stop in the QueryClose but it never got that far.

I get to the form 3 and put in my value and then hit save - then the error pops.  seems to never get to the QueryClose.
OK. Let's try something a little bigger as a test. Surround all the QueryClose code with

Sub Queryclose(Source As Notesuidocument, Continue As Variant)
%REM

{code here}

%END REM
End Sub

Save, and run it again.

If you still get the error then the problem isn't in the QueryClose. If not, it just means the debugger isn't playing fair.

-- b.r.t.
Avatar of Jaziar

ASKER

Ok I did not get the error after doing that
ASKER CERTIFIED SOLUTION
Avatar of TSO Fong
TSO Fong
Flag of Sweden 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

did you copy all the past exchanges for a reason or do I just need to look at the last couple of lines

I placed the %Rem where you said and still got the error
Avatar of Jaziar

ASKER

did this

%REM            
      Set pDoc = db.GetDocumentByUNID(doc.ParentDocumentUNID)
%ENDREM      

and got the error variable not set.  So I am assuming this line is the problem
No, that was an accident. Sorry.

Just to make sure, the original document (on Form 1) that was used to create the e-mail on Form 2, and for which this new document being created on Form 3 will be a response, *does* still exist in the database, doesn't it?
Avatar of Jaziar

ASKER

Yes all 3 forms still exist.  Yes I can see the orig (form 1) in the views - so it is there
Ok. In that view, I presume your response document is showing up, too, right? After all, it's been saved.

So, please, from the view, check the document properties of the presponse document. On the second tab you can get the contents of individual fields. Check the contents of the $Ref field. Write it down -- it's long.

Next get the document properties of the Parent document. Go to the last tab (the beanie) and check the universal ID of the document. Verify that they are the same, please.

-- b.r.t.
Avatar of Jaziar

ASKER

no I am not seeing any response documents.

my select statment is  SELECT Form = "Request" which is form 1

not sure how to set the view up to see the response
Avatar of Jaziar

ASKER

I got the view setup to show responses, I dont think the error ever lets the response be saved.  I am not seeing any responses
The error must not be stopping the document from being saved, because the error is happening in QueryClose, and that comes after the document is saved.

Change the select statement to include Form = "Request" | Form = "Response Form" to see what you're getting.
You can also show that the document is being saved by hitting <Ctrl-S> rather than using your save/close button. <Ctrl-S> will save the document without error, I believe. The error would come when you hit <Esc> to close the document.
Avatar of Jaziar

ASKER

You are correct the document is being saved
Avatar of Jaziar

ASKER

I had someone else test it and they got the Unserival ID error when they selected reply
Which version of Notes are you running? I'm using 5.08, and it's working for me.

If you're on some R6 variation, there may be something squirrelly there we'll have to work through. If you're on a 5, then it's just a difference somehow between what you have set up and what I have set up, and we can track that down (though it may take a while).

-- b.r.t.
Avatar of Jaziar

ASKER

I have had 3 people test it running R5.012 - 2 of the 3 gets universial ID error when they hit reply, the other person gets the error when they save the 3rd form.  So I have not clue.  Any Ideas why we are getting the ID errors on any form.
!

Ick.

No. I don't know yet, but I have some suspicions.

About 2:20 ago, I asked that you check some things from the document properties. Can you please try that now that you have your views showing the documents properly?
Avatar of Jaziar

ASKER

That problemis now fixed - that was a access problem - the user that worked had access the others did not.  So I will try the test as mentioned above
Avatar of Jaziar

ASKER

OK I am not getting a $Ref in my 2nd tab.  I see all the other fields but %Ref
That means the document is not being marked as a response document. There are two places this could be affected:

1) When you create the form, in the designer, the first tab of the form properties should have Response as the type. It should *not* have Document as the type.
2) The Reply button on Form 2 should have this in it somewhere: Call nDoc.MakeResponse(sDoc). At the time this is done, nDoc is the new document (on Form 3) and sDoc is the original request (on Form 1).

As you are not getting an error from the code in No. 2, and that line of code is in what you would have copied and pasted from my original post, I'm guessing No. 1 is our problem.

-- b.r.t.
Avatar of Jaziar

ASKER

form 3 was not setup to be a response form.  I changed that and now the error is object variable not set - I will run the debugger and see if I see where.
Avatar of Jaziar

ASKER

but of course the debugger dont find it.  Could it be where we are trying to write the message back to the comments field on the form 1 - text computed?
I suspect it's on the line:
If Not(item.Contains(doc.UniversalID)) Then

I think I failed to mention that there would be a hidden "Responses" field on Form 1. This is text, computed when composed, value = Responses.

The purpose here is so that if someone opens and re-edits a Form-3 document, it doesn't attach a new line into the Form-1 document. Responses keeps a list of the UNIDs of all its response documents to prevent that.

-- b.r.t.
Also, Responses should be set to allow multiple values.
Avatar of Jaziar

ASKER

Im sorry about all this Barry - this deserves more that 500 points.

Newest error

Couldn't get default view id for database (ecr/ecr20.nsf)
Nah. This wouldn't be nearly so long if I hadn't accidentally copied the entire post back into itself.

This means (not surprisingly) that you don't have a view defined as the default view for the database.

Pick a view that will probably be the most used. Open it in the developer. Go to the view properties. On the second tab, check the first box: "Default when database is first opened".

Try it again.

-- b.r.t.
Avatar of Jaziar

ASKER

The good news - no errors
The Bad News - It did not update the Comments field in the orignal form 1.  I think it should put links it there correct?
Yes, it should.

Did you, by any chance, have the Form 1 document open while all this was going on?

Rich-text fields are kind of weird things in Notes. You can't really do any LotusScript manipulation of them while the document is open because the script only affects the field on the "back end," meaning the document as it resides on the server and not the document as it's open in your client (the "front end" document). Which means, if you had Form 1 open in edit mode when Form 3 was closing, Form 3 would have updated the back-end document, and that update would have been overwritten when you saved Form 1.

If you had Form 1 open in read mode while Form 3 was doing its dirty work, the change wouldn't appear immediately on Form 1, but if you close and reopen it, it should be there.
Avatar of Jaziar

ASKER

It is working - YES!!!  When they reply can it send a email back to the requester?
Avatar of Jaziar

ASKER

Not so worried about it right now - But I will have to have attachements in each form.

They may send a attachment in the first send and then they may have to reply with a attachment
It can. It doesn't at the moment, obviously, but that's not difficult.

Put this in at the end of the QueryClose, inside the If loop (just before End If)

==== BEGIN PASTE ====
            Dim mDoc As NotesDocument
            Set mDoc = New NotesDocument(db)
            mDoc.Form = "Memo"
            mDoc.SendTo = pDoc.Requestor(0)      ' Or whatever field it is you have on Form 1 to capture the name of who made it
            mDoc.Subject = "Response to " & pDoc.Subject(0)      ' Or whatever field you have that would be more descriptive
            Set rtItem = New NoteRichTextItem(mDoc, "Body")
            Call rtItem.AppendText(session.CommonUserName & " has responded")
            Call rtItem.AddNewLine(1)
            Call rtItem.AppendDocLink(doc, "Link to the response")
            Call mDoc.Send(False)
===== END PASTE =====
Avatar of Jaziar

ASKER

     Set rtItem = New NoteRichTextItem(mDoc, "Body") <- Script error
Sorry, that should be NotesRichTextItem.

You can add as many additional fields as you like for various ways to categorize the documents. You can also add another field (called, say, Attachments, maybe) to forms 1 through 3. If you have it on Form 1, all its contents will be copied into Form 2 before it's sent, so the contents would be visible to the mail recipient on Form 2. Form 3 can also have an Attachments field (or whatever else you want to call it) to hold other documents.

Of course, all these would need to be rich-text.

-- b.r.t.
Avatar of Jaziar

ASKER

Everything seems to be working - GREAT!!!

This is just me asking for your opinion on something.

You know how the forms work - I would like a view that shows the data and how the reponses relate to the parent.?

How would you set up a view to best display the relationship?  I can make this a new question if you like
Set the view properties as Show response documents in a hierarchy (checkbox on the second tab of the view properties).

For the column properties of the first column, select Show twistie when row is expandable checkbox on the first tab of the column properties.

That will categorize all the documents, grouped by the main (parent, Form 1) document. If you want, you can also have something like this for the column definition:
@If(@IsResponseDoc; "   Response to "; "") + Subject

See how that does for you.

-- b.r.t.
Avatar of Jaziar

ASKER

Work Greats

I will be out of the Office next, but when I return the next step will be waiting - Thanks for staying with me on all this.
You have done a great job and I appreicate it very much!!
Thanks for the points, Jaziar.

I don't always take the time to monitor the questions, so if the next step is based on the previous three you might need to flag me when you open it. You can do that by posting here, which will send me an e-mail accordingly.

-- b.r.t.
Avatar of Jaziar

ASKER

Hey Barry - Im Back - I am going to post a question about the views refreshing - I can not see the responses unless I leave the view and go back in to the view.  There has to be a way to always see the responses in the view
Does <F9> not do it?
Avatar of Jaziar

ASKER

No
Change your QueryClose to this:

==== BEGIN PASTE ====
Sub Queryclose(Source As Notesuidocument, Continue As Variant)
      Dim session As New NotesSession
      Dim db As NotesDatabase
      Dim doc As NotesDocument
      Dim pDoc As NotesDocument
      Dim item As NotesItem
      Dim rtItem As NotesRichTextItem
      Dim ws As New NotesUIWorkspace
      Dim view As NotesView
      
      If Not Source.EditMode Then
            Exit Sub
      End If
      
      Set doc = Source.Document
      If doc.BeenSaved(0) >< "1" Then
            Exit Sub
      End If
      
      Set db = session.CurrentDatabase
      Set view = db.GetView("Name of your view, Jaziar")
      Call view.Refresh
      Call ws.ViewRefresh
      Set pDoc = db.GetDocumentByUNID(doc.ParentDocumentUNID)
      
      Set item = pDoc.GetFirstItem("Responses")
      If Not(item.Contains(doc.UniversalID)) Then
            ' This response hasn't been done yet.
            Call item.AppendToTextList(doc.UniversalID)
            Set rtItem = pDoc.GetFirstItem("Comments")
            Call rtItem.AppendDocLink(doc, "Link to " & doc.Creator(0) & "'s Reply")
            Call rtItem.AppendText("   (" & doc.Creator(0) & ")  " & doc.Answer(0))
            Call rtItem.AddNewLine(1)
            Call pDoc.Save(True, False)
            
            Dim mDoc As NotesDocument
            Set mDoc = New NotesDocument(db)
            mDoc.Form = "Memo"
            mDoc.SendTo = pDoc.Requestor(0)      ' Or whatever field it is you have on Form 1 to capture the name of who made it
            mDoc.Subject = "Response to " & pDoc.Subject(0)      ' Or whatever field you have that would be more descriptive
            Set rtItem = New NotesRichTextItem(mDoc, "Body")
            Call rtItem.AppendText(session.CommonUserName & " has responded")
            Call rtItem.AddNewLine(1)
            Call rtItem.AppendDocLink(doc, "Link to the response")
            Call mDoc.Send(False)
      End If
End Sub
===== END PASTE =====

The differences are: We now declare a workspace and a view, and now ofter we set the database, we populate the view variable with your view, refresh it on the back-end, and refresh it in the workspace.

See if that does it for you.

-- b.r.t.
Avatar of Jaziar

ASKER

Here is what happens - I open the view and all is expanded, so all the responses show.  If I colapse on a creator and then click the twisties, I never get the responses back - I can how many have replied but not the responses.  So I change views and go back and then they all show up expanded again.
Bizarre. This is less a coding issue and more a gee-this-is-one-of-those-Notes-things issues. I don't know that I'm going to be much help on this one. You might need to open a Q for the heavyweights to hit on.

-- b.r.t.
Avatar of Jaziar

ASKER

I consider you a heavy weight - you have done great work for me.  But I will post the question
I'm a middle-weight, Jaziar. I know development reasonably well, but the heavyweights know development and administration and all the little things that break when you don't expect them to. Notes development isn't actually part of my job title description, and never has been. So I don't get to play with the real big toys...
Avatar of Jaziar

ASKER

Barry I am about ready to ask a new question regarding the stuff we have done.  I wanted to give it you first or at least see if it can be done.

Right now - Parent Document is created and sent out to people the people respond and that creates responses - That works great.  The question is what happens if the people the emails are sent to forward them to other people for assistance?  Is there a way if they forward the email that it still will be a response?  Let me know
I take it that when you forward it now, it's forwarded on the Memo form and loses its action, huh?

One thing you could do would be to take the code that's in the Respond action on your Form 2 and move it into a button on the form rather than a form action.

That will be a little bit less intuitive for people who are used to using the actions at the top of the form to respond to things. But it should work.

If you wanted to, you could put a Respond button on the form in addition to the Respond action, and maybe have it set up so that if the form currently being used to view the document is Form 2 ("Outgoing Request Form"), it's not visible but otherwise it is.

-- b.r.t.
Avatar of Jaziar

ASKER

Here is what is happening - and I dont mind to open a new question and give points for your work.  This has to be very simple for users to use.  The people I am creating this for is very high up and not very techinal.  So what ever we need to do, I am willing to give out the points and make the changes.  

Example of what is needed.

VP of company - goes into  database and creates a so called discussion Thread - he sends it to the 3rd line managers.
if the 3rd managers were to reply to his email we are good (we have that working).  But most of the time the 3rd line will forward the request to thier 2nd line managers to do. (that is were our code breaks).  It would be nice if we had 2 buttons on the form a Start reply (we have today) and a Forward.  The forward could work any way you think it should.  That is what is needed  - a way when the 2nd line managers respond it is recorded as a response.

Please think about it and I can start a new question
OK. That would be an option.

I'm content to follow the question up here.

It should be pretty easy to code a Forward button that will keep the current form (which would then keep the proper Respond and Forward buttons available for the next user). There may be troubles, then, in some of the other references it makes elsewhere, when it gets confused about who sent what. I don't remember the details, but it's nothing that can't be overcome.

I'm cursed with some "real work" on deadline today, so I won't be getting to this immediately. Will that be a problem?

-- b.r.t.
Avatar of Jaziar

ASKER

No - just when ever you can get back to it will be fine.
Put this in an action on the second form, Jaziar:

==== BEGIN 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
      
      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("SendTo")
      item.Values = varNewTo
      
      Call newDoc.Send(True)
      Call uiDoc.Close(True)
End Sub
===== END CODE =====

Note that there are some things about this that could be prettied up a bit. For example, the NotesDocument.Send function replaces whatever is in the From field on the outgoing document with the name of the person who sent it. This is fine and reasonable, for the most part. But it means if your L3 manager sends it to an L2 manager, the L2 manager doesn't know that it's _really_ the VP's request.

To fix that, you'd have to put an additional field on Form 2, say, SenderList, and have the Send script in Form 1 populate it with session.CommonUserName. Then, in the script above, you could have something like:
newDoc.SenderList = "Forwarded by " & session.CommonUserName & Chr$(13) & newDoc.SenderList(0)
in it. (Of course, you would also have to declare the session at the top: Dim session as New NotesSession.)

Make sense?

-- b.r.t.
Avatar of Jaziar

ASKER

Should I call the action - Forward Reply?  Is this working like a forward or do they have to go up to the menu and forward the email?
When they click the Forward action (or whatever you call it), it prompts them for name(s) of who should get it, and then forwards a copy of the document to that person (those people). The document remains in your mailbox, but now also appears in the mailbox(es) of anyone to whom it has been forwarded.

-- b.r.t.
I would think Forward Request would make more sense than Forward Reply. But name it whatever you think will make most sense to your users. Just calling it Forward may be enough.
Avatar of Jaziar

ASKER

Can we put forwarded by John Smith some where in the subject of the email that is sent?

maybe something like Topic + "Forwarded by " + SenderList

So they know it is forwarded
Avatar of Jaziar

ASKER

newDoc.SenderList = "Forwarded by " & session.CommonUserName & Chr$(13) & newDoc.SenderList(0)

I did this - but how would I add it to the subject field on the forward.  Everything else seems to be working well.
Avatar of Jaziar

ASKER

This is just a question.  If the 3rd line forwards it, say it triggers a 3rd form that does not need a reply but instead sends a document to the main form that states the 3rd line forward it - so the main(1st) form would look like this.


replies gathered

[link] John Smith forwarded the request to Chuck Roast <- this would be new
[link] Chuck Roast (this is the way it is now) have chuck's reply and link.

I can open this question and give you much deserved points
If you want to update the Subject field on the forward, you can do that pretty much the same way:

newDoc.Subject = "Fw: " & newDoc.Subject(0)

I think I mentioned earlier that Subject is kind of a "special" field name, in that if you have a Subject field in a document and mail it, that's what will appear in the user's inbox.

-- b.r.t.

OK, now you're trying to make things difficult!

Yes, that can happen, except for the [link] part. (After all, what would you be linking to?)

We already have a field in Form 2 that holds the universal ID of the Form 1 document, and we already have the server and name of the database stored in fields in Form 2. So it wouldn't be too much trouble to lookup the Form 1 doc and add a line to that field.

But I'm about to be sucked into a meeting on federal security compliance, so I'm not sure how helpful I'll be for a little bit... ;-)
Avatar of Jaziar

ASKER

I dont need the link on the forwards - just a note that it was forward.
Add these to the declaractions in the Forward action:

==== BEGIN PASTE ====
      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
===== END PASTE =====

Add this code between the Call newDoc.Send(True) and the Call uiDoc.Close(True):

==== BEGIN PASTE ====
      ' 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("Name of your view, Jaziar")
      Set pDoc = db.GetDocumentByUNID(doc.ParentDocumentUNID)
      
      Set rtItem = pDoc.GetFirstItem("Coments")
      Call rtItem.AppendText("Forwarded to " & item.Text & " by " & session.CommonUserName)
      Call rtItem.AddNewLine(1)
      Call pDoc.Save(True, False)
===== END PASTE =====

It occurs to me that there is no error trapping anywhere in this code. For example, if I send something to you and then delete my request, and then you forward your request, it goes looking for my request and bombs.

Or, it will probably bomb if you decide not to forward it and click Cancel from the address-book PickList window.

You could fix that second one with:
If item.Text = "" Then Exit Sub
right after the line where you assign varNewTo to item.Values.

-- b.r.t.
Avatar of Jaziar

ASKER

Getting Variant does not contain a object - after I put in the address name
Run with debug on, please, and see if it's the line that has:
item.Values = varNewTo

Avatar of Jaziar

ASKER

I will - here is the forward 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
      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("SendTo")
      item.Values = varNewTo
      newDoc.SenderList = "Forwarded by " & session.CommonUserName & Chr$(13) & newDoc.SenderList(0)
      newDoc.Subject = "Fw: " & thisDoc.Subject(0)      
      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("Discussion\By Requester")
      Set pDoc = db.GetDocumentByUNID(doc.ParentDocumentUNID)
      
      Set rtItem = pDoc.GetFirstItem("Coments")
      Call rtItem.AppendText("Forwarded to " & item.Text & " by " & session.CommonUserName)
      Call rtItem.AddNewLine(1)
      Call pDoc.Save(True, False)
      Call uiDoc.Close(True)
End Sub

I very well may have messed things up
Avatar of Jaziar

ASKER

When I debug - It opens the dialog box for the name selection - so then it cant debug but as soon as I say ok after picking the name, I get the error.  SO it never hits the debugger
Avatar of Jaziar

ASKER

I also get a email after I escape the mail
So, then, it is forwarding before it blows up...
Got it. Change
      Set pDoc = db.GetDocumentByUNID(doc.ParentDocumentUNID)
to
      Set pDoc = db.GetDocumentByUNID(thisDoc.SourceDocument(0))

(The hazards of copy-paste code...)
Avatar of Jaziar

ASKER

Now the error say Object Variable not set - happens the same time the last one did
It might help if I spelled things correctly.

Change
     Set rtItem = pDoc.GetFirstItem("Coments")
to
     Set rtItem = pDoc.GetFirstItem("Comments")
Avatar of Jaziar

ASKER

That is very nice - but how would I get rid of the full names - is that possible.

Call rtItem.AppendText("Forwarded to " & item.Text & " by " & session.CommonUserName)
Forwarded to CN=Jaziar Mindstrom/OU=Etc/O=Etc by Chuck Roast

is there a way to get my name CN as well - this stuff is great
So, what you want is:
Forwarded to Jaziar Mindstrom by Chuck Roast
Right?
Avatar of Jaziar

ASKER

yes
Go to right after the End Sub in you command and press Enter to get to the next line. Then, paste this in:
==== BEGIN CODE ====
Function Replace(strWhole As String, strFind As String, strReplace As String) As String
      Dim strOrig As String
      Dim strFirst As String
      Dim strLast As String
      Dim intPlace As Integer
      Dim intFindLength As Integer
      Dim intWholeLength As Integer
      
      strOrig = strWhole
      intPlace = Instr(strReplace, strFind)
      If (intPlace = 0) Or (strReplace = "") Then
            ' Perform the conversion
            intFindLength = Len(strFind)
            intPlace = Instr(strOrig, strFind)
            Do While (intPlace >< 0)
                  intWholeLength = Len(strOrig)
                  strFirst = Left$(strOrig, (intPlace - 1))
                  strLast = Right$(strOrig, intWholeLength - (intPlace + intFindLength) + 1)
                  strOrig = strFirst & strReplace & strLast
                  intPlace = Instr(strOrig, strFind)
            Loop
      End If
      Replace = strOrig
End Function
===== END CODE =====

Then, add
     Dim strToName As String
to the declarations of the Forward subroutine, and change
     Call rtItem.AppendText("Forwarded to " & item.Text & " by " & session.CommonUserName)
to
     strToName = Replace(item.Text, "CN=", "")
     strToName = Replace(strToName, "/OU=Etc/O=Etc", "")
     Call rtItem.AppendText("Forwarded to " & item.Text & " by " & session.CommonUserName)

Note that there would be more efficient ways to do this if we could guarantee that it would never be forwarded to more than one person, but that's a different issue.
Avatar of Jaziar

ASKER

when I paste the code - it turns red and says illegeal duplate end statement
You have to paste this _OUTSIDE_ of any other subroutine. You have to paste AFTER the End Sub statement, so the new function becomes its own entity.
Avatar of Jaziar

ASKER

I did paste it after the end sub

                Call pDoc.Save(True, False)
      Call uiDoc.Close(True)
End Sub

Paste it here and it turns red and errors
OK, try close without saving, then reopen the form. Go to that same place after the End Sub, and type
Function Replace() As String

See what it gives you.

If that works without errors, take the code from above and past it in the middle. Also, make sure you add in the arguments between the parentheses.
Avatar of Jaziar

ASKER

I get unexpected Replace exspected indentifier
Avatar of Jaziar

ASKER

I put in Function R() As String and it worked fine - Think it has something to do with the Replace
What version of Notes are you running, Jaziar?
Avatar of Jaziar

ASKER

I am using R6 users are still R5
That may be the issue. It's possible they've added a built-in replace function in R6 that R5 doesn't have. I've always just written my own.

What happens if instead of Function Replace() As String, you type Function StringReplace() As String?
Avatar of Jaziar

ASKER

works and creats a function
OK, then paste in all the code from my Replace function, and then also change the two lines where I invoked that function to use the function StringReplace instead. Also, again, remember to put the passed parameters in the parentheses in the function signature...
Avatar of Jaziar

ASKER

This look right

Function StringReplace(strWhole As String, strFind As String, strReplace As String) As String
      Dim strOrig As String
      Dim strFirst As String
      Dim strLast As String
      Dim intPlace As Integer
      Dim intFindLength As Integer
      Dim intWholeLength As Integer
      
      strOrig = strWhole
      intPlace = Instr(strReplace, strFind)
      If (intPlace = 0) Or (strReplace = "") Then
          ' Perform the conversion
            intFindLength = Len(strFind)
            intPlace = Instr(strOrig, strFind)
            Do While (intPlace >< 0)
                  intWholeLength = Len(strOrig)
                  strFirst = Left$(strOrig, (intPlace - 1))
                  strLast = Right$(strOrig, intWholeLength - (intPlace + intFindLength) + 1)
                  strOrig = strFirst & strReplace & strLast
                  intPlace = Instr(strOrig, strFind)
            Loop
      End If
      StringReplace = strOrig
End Function
Avatar of Jaziar

ASKER

I can not find where you are calling this function in the code
Check my post from not quite 50 minutes ago, when you started getting this pasting error. At the end of those instructions were some instructions you probably never got too...

-- b.r.t.
Avatar of Jaziar

ASKER

I guess where it never saved I lost those changes - let me try again
Avatar of Jaziar

ASKER

Still getting the same thing - here is my code

Forward Response

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
      Set uiDoc = ws.CurrentDocument
      Set thisDoc = uiDoc.Document
      Set db = thisDoc.ParentDatabase
      Dim strToName As String
      Set newDoc = New NotesDocument(db)
      Call thisDoc.CopyAllItems(newDoc, True)
      
      varNewTo = ws.PickListStrings(PICKLIST_NAMES, True)
      Set item = newDoc.GetFirstItem("SendTo")
      item.Values = varNewTo
Is this ok ->newDoc.SenderList = "Forwarded by " & session.CommonUserName & Chr$(13) & newDoc.SenderList(0)
is This ->      newDoc.Subject = "Fw: " & thisDoc.Subject(0)      
      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("Discussion\By Requester")
      Set pDoc = db.GetDocumentByUNID(thisDoc.SourceDocument(0))
      Set rtItem = pDoc.GetFirstItem("Comments")
      strToName = StringReplace(item.Text, "CN=", "")
      strToName = StringReplace(strToName, "/OU=Etc/O=Etc", "")
should this call strToName?->      Call rtItem.AppendText("Forwarded to " & item.Text & " by " & session.CommonUserName)
      Call rtItem.AddNewLine(1)
      Call pDoc.Save(True, False)
      Call uiDoc.Close(True)
End Sub

Declarations

Dim strOrig As String
Dim strFirst As String
Dim strLast As String
Dim intPlace As Integer
Dim intFindLength As Integer
Dim intWholeLength As Integer


Function StringReplace(strWhole As String, strFind As String, strReplace As String) As String
      Dim strOrig As String
      Dim strFirst As String
      Dim strLast As String
      Dim intPlace As Integer
      Dim intFindLength As Integer
      Dim intWholeLength As Integer
      
      strOrig = strWhole
      intPlace = Instr(strReplace, strFind)
      If (intPlace = 0) Or (strReplace = "") Then
          ' Perform the conversion
            intFindLength = Len(strFind)
            intPlace = Instr(strOrig, strFind)
            Do While (intPlace >< 0)
                  intWholeLength = Len(strOrig)
                  strFirst = Left$(strOrig, (intPlace - 1))
                  strLast = Right$(strOrig, intWholeLength - (intPlace + intFindLength) + 1)
                  strOrig = strFirst & strReplace & strLast
                  intPlace = Instr(strOrig, strFind)
            Loop
      End If
      StringReplace = strOrig
End Function
Yes, it should. (D'oh!)
Avatar of Jaziar

ASKER

Have a great weekend - I am heading home.  There is another 500 point question coming Monday.  I would like for you to have it.

Thanks for everything thus far
You're welcome, Jaziar.
Avatar of Jaziar

ASKER

Barry I am still getting

Forwarded to CN=Bud Wise/OU=Etc/O=Etc by Joe Smoe

I will go in and check the calls again - But I putting my code in here to see if you see something I am missing

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
      Set uiDoc = ws.CurrentDocument
      Set thisDoc = uiDoc.Document
      Set db = thisDoc.ParentDatabase
      Dim strToName As String
      Set newDoc = New NotesDocument(db)
      Call thisDoc.CopyAllItems(newDoc, True)
      
      varNewTo = ws.PickListStrings(PICKLIST_NAMES, True)
      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)      
      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("Discussion\By Requester")
      Set pDoc = db.GetDocumentByUNID(thisDoc.SourceDocument(0))
      Set rtItem = pDoc.GetFirstItem("Comments")
      strToName = StringReplace(item.Text, "CN=", "")
      strToName = StringReplace(strToName, "/OU=Etc/O=Etc", "")
      Call rtItem.AppendText("Forwarded to " & strToName & " by " & session.CommonUserName)
      Call rtItem.AddNewLine(1)
      Call pDoc.Save(True, False)
      Call uiDoc.Close(True)
End Sub


Function StringReplace(strWhole As String, strFind As String, strReplace As String) As String
      Dim strOrig As String
      Dim strFirst As String
      Dim strLast As String
      Dim intPlace As Integer
      Dim intFindLength As Integer
      Dim intWholeLength As Integer
      
      strOrig = strWhole
      intPlace = Instr(strReplace, strFind)
      If (intPlace = 0) Or (strReplace = "") Then
          ' Perform the conversion
            intFindLength = Len(strFind)
            intPlace = Instr(strOrig, strFind)
            Do While (intPlace >< 0)
                  intWholeLength = Len(strOrig)
                  strFirst = Left$(strOrig, (intPlace - 1))
                  strLast = Right$(strOrig, intWholeLength - (intPlace + intFindLength) + 1)
                  strOrig = strFirst & strReplace & strLast
                  intPlace = Instr(strOrig, strFind)
            Loop
      End If
      StringReplace = strOrig
End Function


Barry I am also starting a new question - I will put your name in the question something like Question For Barry -> then the question.
Jaziar --

I suspect that while you have made the changes to the code in the database, you may still be testing this functionality with a document that was e-mailed to you before the changes were put in place.

This code fix is to Form 2, and Form 2 is stored with outgoing e-mails. If you sent an e-mail (by creating an original request) before this code was in place, the Form 2 code that would have been sent with that e-mail would not include the new code. Even though the code in the main db is now correct, it is never run as the running code is that stored in the form in the e-mail.

Please confirm that you are testing this with a brand new message thread, and that it's still not working.

-- b.r.t.
Avatar of Jaziar

ASKER

OK with a new message here is what is showing up - there is a differnce

Forwarded to Joe Smoe/OU=Etc/O=Etc by Jaziar Mindstrom

looks like is parsed the CN=
Avatar of Jaziar

ASKER

got that working!!! YEA  It was a oversight on my side.
Let me guess -- you had left the code as /OU=Etc/O=Etc instead of changing it to your OU and O?
Avatar of Jaziar

ASKER

yep - :)
Avatar of Jaziar

ASKER

You still out there?