Jaziar
asked on
Adding a comment to a email and a field
I have a table on my form - it has 20 rows. The top row has no fields but has a action button. The rest of the rows have a editable text field on each row. Here is what I want, if it can be done?
when the user hits the action button - a form/dialog box appears - with a sendto field and comment field. The user selects who he wants to send the email to and then adds their comments - the user hits send and the email is sent with the comment to the selected user. Then the comment is added to the 20 rows table on the form. So the comment is saved on the form.
If this makes no sense I can try to it again.
Jaziar
when the user hits the action button - a form/dialog box appears - with a sendto field and comment field. The user selects who he wants to send the email to and then adds their comments - the user hits send and the email is sent with the comment to the selected user. Then the comment is added to the 20 rows table on the form. So the comment is saved on the form.
If this makes no sense I can try to it again.
Jaziar
Can be done... realizing the 20 limit
Note: Much easier in script than formula
Jaziar,
"when the user hits the action button - a form/dialog box appears - with a sendto field and comment field." - so the user enters comments, but how do u want it to be split across the 20 editable text fields...
Partha
"when the user hits the action button - a form/dialog box appears - with a sendto field and comment field." - so the user enters comments, but how do u want it to be split across the 20 editable text fields...
Partha
REM Let's assume at this point you have already gotten the input, and sent off the e-Mail.
REM The comment text is in a variable named COMMENT.
REM The message recipient is in a variable named RECIPIENT.
REM The table has four columns.
REM Except for the first row, the first column contains fields CmntDate_1, CmntDate_2, ... , CmntDate_20
REM Second column contains fields CmntFrom_1, ..., CmntFrom_20
REM Third column contains fields CmntTo_1, ... , CmntTo_20
REM Fourth column contains Cmnttext_1 , ..., CmntText_20
Dim s as new NotesSession
Dim ws as New NotesUiWorkspace
Dim uiDoc as notesUiDocument
Set uiDoc = ws.currentDocument
Dim doc as notesDocument
Set doc = uiDoc.Document
Dim i as integer
For i = 1 to 20
If doc.getItemValue("CmntFrom _" & i)(0) = "" Then
doc.replaceItemValue "CmntFrom_" & i , s.userName
doc.replaceItemValue "CmntText_" & i , COMMENT
doc.replaceItemValue "CmntTo_" & i , RECIPIENT
doc.replaceItemValue "CmntDate_" & i , Now
ElseIf i = 20 Then
MsgBox "Your comment was sent, but it could not be recorded here because the table was full."
End If
Next
REM The comment text is in a variable named COMMENT.
REM The message recipient is in a variable named RECIPIENT.
REM The table has four columns.
REM Except for the first row, the first column contains fields CmntDate_1, CmntDate_2, ... , CmntDate_20
REM Second column contains fields CmntFrom_1, ..., CmntFrom_20
REM Third column contains fields CmntTo_1, ... , CmntTo_20
REM Fourth column contains Cmnttext_1 , ..., CmntText_20
Dim s as new NotesSession
Dim ws as New NotesUiWorkspace
Dim uiDoc as notesUiDocument
Set uiDoc = ws.currentDocument
Dim doc as notesDocument
Set doc = uiDoc.Document
Dim i as integer
For i = 1 to 20
If doc.getItemValue("CmntFrom
doc.replaceItemValue "CmntFrom_" & i , s.userName
doc.replaceItemValue "CmntText_" & i , COMMENT
doc.replaceItemValue "CmntTo_" & i , RECIPIENT
doc.replaceItemValue "CmntDate_" & i , Now
ElseIf i = 20 Then
MsgBox "Your comment was sent, but it could not be recorded here because the table was full."
End If
Next
The fields on the table should all be computed when composed, with a null string formula ("")
You can transfer the values using this script.
THis is a prototype, let me know if you don't get it
Sub Click(Source As Button)
Dim session As New NotesSession
Dim doc As NotesDocument, dialog As NotesDocument
Dim ws As New NotesUIWorkspace
' Call the dialog.
Set db = session.CUrrentDatabase
Set dialog = db.CreateDocument
flag = ws.DialogBox( "DialogForm", 1,1, 0, 1, 1, 0, "title", dialog)
' Transfer the values to the fields.
Set doc = ws.CurrentDocument.Documen t
For i = 1 To 20
s = doc.GetItemValue( "SendTo_" & i )
If s = "" Then
Call doc.ReplaceItemValue( "SendTo_" & i , dialog.SendTo)
Call doc.ReplaceItemValue( "Comments_" & i , dialog.Comments)
Exit Sub
End If
Next i
End Sub
~Hemanth
THis is a prototype, let me know if you don't get it
Sub Click(Source As Button)
Dim session As New NotesSession
Dim doc As NotesDocument, dialog As NotesDocument
Dim ws As New NotesUIWorkspace
' Call the dialog.
Set db = session.CUrrentDatabase
Set dialog = db.CreateDocument
flag = ws.DialogBox( "DialogForm", 1,1, 0, 1, 1, 0, "title", dialog)
' Transfer the values to the fields.
Set doc = ws.CurrentDocument.Documen
For i = 1 To 20
s = doc.GetItemValue( "SendTo_" & i )
If s = "" Then
Call doc.ReplaceItemValue( "SendTo_" & i , dialog.SendTo)
Call doc.ReplaceItemValue( "Comments_" & i , dialog.Comments)
Exit Sub
End If
Next i
End Sub
~Hemanth
I forgot to include the cancel action , here is the corrected code
Sub Click(Source As Button)
Dim session As New NotesSession
Dim doc As NotesDocument, dialog As NotesDocument
Dim ws As New NotesUIWorkspace
' Call the dialog.
Set db = session.CUrrentDatabase
Set dialog = db.CreateDocument
flag = ws.DialogBox( "DialogForm", 1,1, 0, 1, 1, 0, "title", dialog)
' Transfer the values to the fields.
If flag Then
Set doc = ws.CurrentDocument.Documen t
For i = 1 To 20
s = doc.GetItemValue( "SendTo_" & i )
If s = "" Then
Call doc.ReplaceItemValue( "SendTo_" & i , dialog.SendTo)
Call doc.ReplaceItemValue( "Comments_" & i , dialog.Comments)
Exit Sub
End If
Next i
End If
End Sub
Sub Click(Source As Button)
Dim session As New NotesSession
Dim doc As NotesDocument, dialog As NotesDocument
Dim ws As New NotesUIWorkspace
' Call the dialog.
Set db = session.CUrrentDatabase
Set dialog = db.CreateDocument
flag = ws.DialogBox( "DialogForm", 1,1, 0, 1, 1, 0, "title", dialog)
' Transfer the values to the fields.
If flag Then
Set doc = ws.CurrentDocument.Documen
For i = 1 To 20
s = doc.GetItemValue( "SendTo_" & i )
If s = "" Then
Call doc.ReplaceItemValue( "SendTo_" & i , dialog.SendTo)
Call doc.ReplaceItemValue( "Comments_" & i , dialog.Comments)
Exit Sub
End If
Next i
End If
End Sub
Hemantha's script looks almost exactly like my script! :)
He adds some code for getting the values (which I did not), but I have a place to record the sender and recipient (which he does not). Neither of us bothered with the mail sending, which is not difficult:
Dim s as new notesSession
Dim db as notesDatabase
Set db = s.currentdatabase
Dim message as notesDocument
Set message = db.createDocument
message.Form = "Memo"
message.Subject = "Comment from database " & db.Title
message.Body = COMMENT
message.SendTo = RECIPIENT
message.Send false
He adds some code for getting the values (which I did not), but I have a place to record the sender and recipient (which he does not). Neither of us bothered with the mail sending, which is not difficult:
Dim s as new notesSession
Dim db as notesDatabase
Set db = s.currentdatabase
Dim message as notesDocument
Set message = db.createDocument
message.Form = "Memo"
message.Subject = "Comment from database " & db.Title
message.Body = COMMENT
message.SendTo = RECIPIENT
message.Send false
ASKER
Not to mess things up but would it be easier and cleaner to append all the comments in one field verses having the 20 rows?
It would be sortof cleaner, but you would have a UI problem, if you wanted to line up names with their comments. The comments would wrap, taking up multiple lines, and you would have no way to keep the matching names/dates in line with their comments.
Another way to do this would be to have one bug mega field containing names, dates, and comments, which you would then have trouble parsing out later iof you ever wanted to. Something like this:
Set history = doc.getFirstItem("CommentH istory")
history.AppendToTextItem Now & " From " & RECIPIENT & " To " & s.userName & Chr$(13)
history.AppendToTextItem "------------------------- ---------- ---------- ---------" & Chr$(13)
history.AppendToTextItem COMMENT & Chr$(13)
history.AppendToTextItem "========================= ========== ========== =========" & Chr$(13)
doc.replaceItemValue "CmntText_" & i , COMMENT
doc.replaceItemValue "CmntTo_" & i , RECIPIENT
doc.replaceItemValue "CmntDate_" & i , Now
Another way to do this would be to have one bug mega field containing names, dates, and comments, which you would then have trouble parsing out later iof you ever wanted to. Something like this:
Set history = doc.getFirstItem("CommentH
history.AppendToTextItem Now & " From " & RECIPIENT & " To " & s.userName & Chr$(13)
history.AppendToTextItem "-------------------------
history.AppendToTextItem COMMENT & Chr$(13)
history.AppendToTextItem "=========================
doc.replaceItemValue "CmntText_" & i , COMMENT
doc.replaceItemValue "CmntTo_" & i , RECIPIENT
doc.replaceItemValue "CmntDate_" & i , Now
Oops, drop the last thre lines, left over from previous comment
Another oops, not AppendTotextItem, but AppendToTextList
ASKER
Qwaletee would that code go in to the action button or would it be the value for the text field. What interface am I using to get the email address and comment - does it pop up a form or a prompt? I am little lost
ASKER
I created a form named Desc
sendto = DescSendTo
comment = DiscComment
I put a button on there that does this
Mail := @Trim(DiscSendTo);
subject := "Testing Email";
message := @NewLine + @NewLine + DiscComment + @NewLine + @NewLine + "Testing";
@MailSend(Mail; ""; "";subject; ""; message + @NewLine+@NewLine);
@Command([FileCloseWindow] )
So that sends the comment to the address - works fine - Now I need to figure out to add this piece with that you guys have up there. I would like just to append the comment - username - date to the same field. I think we are getting there.
sendto = DescSendTo
comment = DiscComment
I put a button on there that does this
Mail := @Trim(DiscSendTo);
subject := "Testing Email";
message := @NewLine + @NewLine + DiscComment + @NewLine + @NewLine + "Testing";
@MailSend(Mail; ""; "";subject; ""; message + @NewLine+@NewLine);
@Command([FileCloseWindow]
So that sends the comment to the address - works fine - Now I need to figure out to add this piece with that you guys have up there. I would like just to append the comment - username - date to the same field. I think we are getting there.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
include doc.Form = "Memo" in the above script
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Are you using R6 ? If you use R6 you can create a dynamic table, that will grow however large you want. You can also use passtru html in r6 to build the table from several multi-value fields (enable show passtru html in Notes).
Another approach to create a similar effect would be to create separate documents for your comments, as responses. Now create a view, with a categorized first column, @text($Ref).
Put in the next columns the fields you like to show, and sort them how you would like.
Now include that view as embedded view, show single category in your form.
Now you have a dynamically growing comments list. In R6, you can go 1 step further, and use the new InviewEdit feature, to allow people to fill in the form tru the embedded view.
To create the responses, simple use (if newResponse is a response document)
@command([compose]; "newResponse" )
cheers,
Tom
Another approach to create a similar effect would be to create separate documents for your comments, as responses. Now create a view, with a categorized first column, @text($Ref).
Put in the next columns the fields you like to show, and sort them how you would like.
Now include that view as embedded view, show single category in your form.
Now you have a dynamically growing comments list. In R6, you can go 1 step further, and use the new InviewEdit feature, to allow people to fill in the form tru the embedded view.
To create the responses, simple use (if newResponse is a response document)
@command([compose]; "newResponse" )
cheers,
Tom
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Set history = doc.getFirstItem("CommentH istory")
Is this getting the field on the main form that I want to display to? So it is getting the value of CommentHistory(which on my form is comments) and appending the new info?
comment = dialog.comment(0)
recipient = dialog.recipient(0)
Is this is getting the values from the dialog form?
Dim message as notesDocument
Set message = db.createDocument
message.Form = "Memo"
message.Subject = "Comment from database " & db.Title
message.Body = COMMENT
message.SendTo = RECIPIENT
message.Send false
What exactly is this doing? Is it setting up a email?
When I run what you have in the action button - my form comes up and I can add the email address and comment - on that form I have a send email button - I click it and the email is sent and the form is closed. I am now sitting back at my master form. But no Info has been added to the comment section.
Is this getting the field on the main form that I want to display to? So it is getting the value of CommentHistory(which on my form is comments) and appending the new info?
comment = dialog.comment(0)
recipient = dialog.recipient(0)
Is this is getting the values from the dialog form?
Dim message as notesDocument
Set message = db.createDocument
message.Form = "Memo"
message.Subject = "Comment from database " & db.Title
message.Body = COMMENT
message.SendTo = RECIPIENT
message.Send false
What exactly is this doing? Is it setting up a email?
When I run what you have in the action button - my form comes up and I can add the email address and comment - on that form I have a send email button - I click it and the email is sent and the form is closed. I am now sitting back at my master form. But no Info has been added to the comment section.
ASKER
OK I have removed the send email button from the subform. I see the code above sends a email. Now all I need to know is how to get the variable from the form and update it with the dialog values? I am sure it is in front of my face, but I am missing it.
ASKER
Set doc = ws.currentDocument.documen t
Set history = doc.getFirstItem("Discussi on")
history.AppendToTextList Now & " From " & RECIPIENT & " To " & s.userName & Chr$(13)
history.AppendToTextList "------------------------- ---------- ---------- ---------" & Chr$(13)
history.AppendToTextList COMMENT & Chr$(13)
history.AppendToTextList "========================= ========== ========== =========" & Chr$(13)
doc.save True,True
End Sub
Set history = doc.getFirstItem("Discussi on") <- Discussion is the name of the text field (Computed) I want to append all the text to.
When I hit ok on the subform I get the following error, but I still get the email
Variant does not contain an object
Set history = doc.getFirstItem("Discussi
history.AppendToTextList Now & " From " & RECIPIENT & " To " & s.userName & Chr$(13)
history.AppendToTextList "-------------------------
history.AppendToTextList COMMENT & Chr$(13)
history.AppendToTextList "=========================
doc.save True,True
End Sub
Set history = doc.getFirstItem("Discussi
When I hit ok on the subform I get the following error, but I still get the email
Variant does not contain an object
Yes that won't work if you have a new document.
If you want the script to work, Discussion must be a Computed when composed text field, or Computed with formula : Discussion
..
set history = doc.getfirstitem( "Discussion" )
if history is nothing then
set history = doc.replaceitemvalue( "Discussion" , Now & " From " & RECIPIENT & " To " & s.userName & Chr$(13) )
else
history.AppendToTextList Now & " From " & RECIPIENT & " To " & s.userName & Chr$(13)
end if
history.AppendToTextList "------------------------- ---------- ---------- ---------" & Chr$(13)
history.AppendToTextList COMMENT & Chr$(13)
history.AppendToTextList "========================= ========== ========== =========" & Chr$(13)
doc.save True,True
...
Are you using R5 or R6 ?
cheers,
Tom
If you want the script to work, Discussion must be a Computed when composed text field, or Computed with formula : Discussion
..
set history = doc.getfirstitem( "Discussion" )
if history is nothing then
set history = doc.replaceitemvalue( "Discussion" , Now & " From " & RECIPIENT & " To " & s.userName & Chr$(13) )
else
history.AppendToTextList Now & " From " & RECIPIENT & " To " & s.userName & Chr$(13)
end if
history.AppendToTextList "-------------------------
history.AppendToTextList COMMENT & Chr$(13)
history.AppendToTextList "=========================
doc.save True,True
...
Are you using R5 or R6 ?
cheers,
Tom
ASKER
R5
ASKER
I get the same error - does the form need to be refreshed to see the changes?
ASKER
My Problem Is Diffently in
Set doc = ws.currentDocument.documen t
Set history = doc.getfirstitem( "Discussion" )
If history Is Nothing Then
Set history = doc.replaceitemvalue( "Discussion" , Now & " From " & RECIPIENT & " To " & s.userName & Chr$(13) )
Else
history.AppendToTextList Now & " From " & RECIPIENT & " To " & s.userName & Chr$(13)
End If
history.AppendToTextList "------------------------- ---------- ---------- ---------" & Chr$(13)
history.AppendToTextList COMMENT & Chr$(13)
history.AppendToTextList "========================= ========== ========== =========" & Chr$(13)
doc.save True,True
It seems to me and I dont fully understand the error that doc.getfirstitem( "Discussion" ) is not working correctly. Could it be trying to get Discussion off the subform? instead of the main form? Just a question
Set doc = ws.currentDocument.documen
Set history = doc.getfirstitem( "Discussion" )
If history Is Nothing Then
Set history = doc.replaceitemvalue( "Discussion" , Now & " From " & RECIPIENT & " To " & s.userName & Chr$(13) )
Else
history.AppendToTextList Now & " From " & RECIPIENT & " To " & s.userName & Chr$(13)
End If
history.AppendToTextList "-------------------------
history.AppendToTextList COMMENT & Chr$(13)
history.AppendToTextList "=========================
doc.save True,True
It seems to me and I dont fully understand the error that doc.getfirstitem( "Discussion" ) is not working correctly. Could it be trying to get Discussion off the subform? instead of the main form? Just a question
Where is this discussion item located. Main form or Dialog ? And what is the error ?
ASKER
Discussion is in the main form - Discussion is the field I want to append all the text comments to
The error is
Variant does not contain an object
The error is
Variant does not contain an object
It doesn't really matter where the discussion item is.
I would change the script (again) though, because now, it does changes in the backend that are not reflected immediately in the front end.
'Set doc = ws.currentDocument.documen t <--- remove this line
set uidoc = ws.currentDocument
Set history = uidoc.document.getfirstite m( "Discussion" )
If history Is Nothing Then
Set history = uidoc.document.replaceitem value( "Discussion" , Now & " From " & RECIPIENT & " To " & s.userName & Chr$(13) )
Else
history.AppendToTextList Now & " From " & RECIPIENT & " To " & s.userName & Chr$(13)
End If
history.AppendToTextList "------------------------- ---------- ---------- ---------" & Chr$(13)
history.AppendToTextList COMMENT & Chr$(13)
history.AppendToTextList "========================= ========== ========== =========" & Chr$(13)
' save it in the backend, but update changes
call uidoc.document.save(True,T rue)
Call uidoc.reload()
Tom
I would change the script (again) though, because now, it does changes in the backend that are not reflected immediately in the front end.
'Set doc = ws.currentDocument.documen
set uidoc = ws.currentDocument
Set history = uidoc.document.getfirstite
If history Is Nothing Then
Set history = uidoc.document.replaceitem
Else
history.AppendToTextList Now & " From " & RECIPIENT & " To " & s.userName & Chr$(13)
End If
history.AppendToTextList "-------------------------
history.AppendToTextList COMMENT & Chr$(13)
history.AppendToTextList "=========================
' save it in the backend, but update changes
call uidoc.document.save(True,T
Call uidoc.reload()
Tom
in the options section of you button, put
Option Declare
That will help you find potential problems....
cheers,
Tom
Option Declare
That will help you find potential problems....
cheers,
Tom
ASKER
1. Set db = session.CUrrentDatabase => RED
2. flag = ws.DialogBox( "Disc", 1,1, 0, 1, 1, 0, "title", dialog) => RED w/error Variable not declared: flag
3. Set uidoc = ws.currentDocument => RED w/error Variable not declared: uidoc
4. Set history = uidoc.document.getfirstite m( "Discussion" ) => RED w/error Variable not declared: history
5. Set history = uidoc.document.replaceitem value( "Discussion" , Now & " From " & RECIPIENT & " To " & s.userName & Chr$(13) ) => did not show up in RED but has a error of Variable not declared : S
I think I am so close!
2. flag = ws.DialogBox( "Disc", 1,1, 0, 1, 1, 0, "title", dialog) => RED w/error Variable not declared: flag
3. Set uidoc = ws.currentDocument => RED w/error Variable not declared: uidoc
4. Set history = uidoc.document.getfirstite
5. Set history = uidoc.document.replaceitem
I think I am so close!
ASKER
Should I do a DIM history As String -> that will declare the field
After I do that I am down to one error and that is in this line
Dim Discussion As String, history As String
Set history = uidoc.document.getfirstite m( "Discussion" )
If history Is Nothing Then
Set history = uidoc.document.replaceitem value( "Discussion" , Now & " From " & RECIPIENT & " To " & s.userName & Chr$(13) )
Else
=>=>=>**history.AppendToTe xtList Now & " From " & RECIPIENT & " To " & s.userName & Chr$(13) <= ERROR Not A Instance Name: History
End If
history.AppendToTextList "------------------------- ---------- ---------- ---------" & Chr$(13)
history.AppendToTextList COMMENT & Chr$(13)
history.AppendToTextList "========================= ========== ========== =========" & Chr$(13)
After I do that I am down to one error and that is in this line
Dim Discussion As String, history As String
Set history = uidoc.document.getfirstite
If history Is Nothing Then
Set history = uidoc.document.replaceitem
Else
=>=>=>**history.AppendToTe
End If
history.AppendToTextList "-------------------------
history.AppendToTextList COMMENT & Chr$(13)
history.AppendToTextList "=========================
ASKER
Here is my Complete Code I have right now---- See Below
Sub Click(Source As Button)
Dim session As New NotesSession
Dim uiDoc As notesUiDocument
Dim doc As NotesDocument, dialog As NotesDocument
Dim ws As New NotesUIWorkspace
Dim s As New NotesSession
Dim db As NotesDatabase
Set db = session.CUrrentDatabase
Set dialog = db.CreateDocument
Set uiDoc = ws.currentDocument
Dim flag As String
flag = ws.DialogBox( "Disc", 1,1, 0, 1, 1, 0, "title", dialog)
If Not flag Then Exit Sub
Dim comment As String, recipient As String
comment = dialog.DiscComment(0)
recipient = dialog.DiscSendTo(0)
Dim message As notesDocument
Set message = db.createDocument
message.Form = "Memo"
message.Subject = "Discussion Thread from database " & db.Title
message.Body = COMMENT
message.SendTo = RECIPIENT
message.Send False
Set uidoc = ws.currentDocument
Dim Discussion As String, history As String
Set history = uidoc.document.getfirstite m( "Discussion" )
If history Is Nothing Then
Set history = uidoc.document.replaceitem value( "Discussion" , Now & " From " & RECIPIENT & " To " & s.userName & Chr$(13) )
Else
history.AppendToTextList Now & " From " & RECIPIENT & " To " & s.userName & Chr$(13)
End If
history.AppendToTextList "------------------------- ---------- ---------- ---------" & Chr$(13)
history.AppendToTextList COMMENT & Chr$(13)
history.AppendToTextList "========================= ========== ========== =========" & Chr$(13)
' save it in the backend, but update changes
Call uidoc.document.save(True,T rue)
Call uidoc.reload()
End Sub
Sub Click(Source As Button)
Dim session As New NotesSession
Dim uiDoc As notesUiDocument
Dim doc As NotesDocument, dialog As NotesDocument
Dim ws As New NotesUIWorkspace
Dim s As New NotesSession
Dim db As NotesDatabase
Set db = session.CUrrentDatabase
Set dialog = db.CreateDocument
Set uiDoc = ws.currentDocument
Dim flag As String
flag = ws.DialogBox( "Disc", 1,1, 0, 1, 1, 0, "title", dialog)
If Not flag Then Exit Sub
Dim comment As String, recipient As String
comment = dialog.DiscComment(0)
recipient = dialog.DiscSendTo(0)
Dim message As notesDocument
Set message = db.createDocument
message.Form = "Memo"
message.Subject = "Discussion Thread from database " & db.Title
message.Body = COMMENT
message.SendTo = RECIPIENT
message.Send False
Set uidoc = ws.currentDocument
Dim Discussion As String, history As String
Set history = uidoc.document.getfirstite
If history Is Nothing Then
Set history = uidoc.document.replaceitem
Else
history.AppendToTextList Now & " From " & RECIPIENT & " To " & s.userName & Chr$(13)
End If
history.AppendToTextList "-------------------------
history.AppendToTextList COMMENT & Chr$(13)
history.AppendToTextList "=========================
' save it in the backend, but update changes
Call uidoc.document.save(True,T
Call uidoc.reload()
End Sub
Declare history as item, like this
Dim history as NotesItem
Dim history as NotesItem
ASKER
I made that change and now I am getting a type mismatch
ASKER
OK I have resolved the problems - YaaHoo
There are 2 issues left
1. When I put more than one email in the sendto - it only emails the first name?
2. The username is full cn=bob socks etc - I would like it in @Name([CN]; @username)?
There are 2 issues left
1. When I put more than one email in the sendto - it only emails the first name?
2. The username is full cn=bob socks etc - I would like it in @Name([CN]; @username)?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
oops one change...
Dim session As New NotesSession
Dim uiDoc As notesUiDocument
Dim doc As NotesDocument, dialog As NotesDocument
Dim ws As New NotesUIWorkspace
Dim s As New NotesSession
Dim db As NotesDatabase
Set db = session.CUrrentDatabase
Set dialog = db.CreateDocument
Set uiDoc = ws.currentDocument
Dim flag As String
flag = ws.DialogBox( "Disc", 1,1, 0, 1, 1, 0, "title", dialog)
If Not flag Then Exit Sub
Dim comment As String, recipient As String
comment = dialog.DiscComment(0)
recipient = dialog.DiscSendTo(0)
Dim message As notesDocument
Set message = db.createDocument
message.Form = "Memo"
message.Subject = "Discussion Thread from database " & db.Title
message.Body = COMMENT
message.SendTo = dialog.DiscSendTo
message.Send False
Set uidoc = ws.currentDocument
Dim Discussion As String, history As String
Set history = uidoc.document.getfirstite m( "Discussion" )
If history Is Nothing Then
Set history = uidoc.document.replaceitem value( "Discussion" , Now & " From " & RECIPIENT & " To " & s.commonuserName & Chr$(13) )
Else
history.AppendToTextList Now & " From " & RECIPIENT & " To " & s.commonuserName & Chr$(13)
End If
history.AppendToTextList "------------------------- ---------- ---------- ---------" & Chr$(13)
history.AppendToTextList COMMENT & Chr$(13)
history.AppendToTextList "========================= ========== ========== =========" & Chr$(13)
' save it in the backend, but update changes
Call uidoc.document.save(True,T rue)
Call uidoc.reload()
Partha
Dim session As New NotesSession
Dim uiDoc As notesUiDocument
Dim doc As NotesDocument, dialog As NotesDocument
Dim ws As New NotesUIWorkspace
Dim s As New NotesSession
Dim db As NotesDatabase
Set db = session.CUrrentDatabase
Set dialog = db.CreateDocument
Set uiDoc = ws.currentDocument
Dim flag As String
flag = ws.DialogBox( "Disc", 1,1, 0, 1, 1, 0, "title", dialog)
If Not flag Then Exit Sub
Dim comment As String, recipient As String
comment = dialog.DiscComment(0)
recipient = dialog.DiscSendTo(0)
Dim message As notesDocument
Set message = db.createDocument
message.Form = "Memo"
message.Subject = "Discussion Thread from database " & db.Title
message.Body = COMMENT
message.SendTo = dialog.DiscSendTo
message.Send False
Set uidoc = ws.currentDocument
Dim Discussion As String, history As String
Set history = uidoc.document.getfirstite
If history Is Nothing Then
Set history = uidoc.document.replaceitem
Else
history.AppendToTextList Now & " From " & RECIPIENT & " To " & s.commonuserName & Chr$(13)
End If
history.AppendToTextList "-------------------------
history.AppendToTextList COMMENT & Chr$(13)
history.AppendToTextList "=========================
' save it in the backend, but update changes
Call uidoc.document.save(True,T
Call uidoc.reload()
Partha
ASKER
OK I know this is getting old - but I will make it worth the time
When the field is empty it works fine, but when there is already some data in the field I get this error when I click the button
Document Command Is Not avaiable
When the field is empty it works fine, but when there is already some data in the field I get this error when I click the button
Document Command Is Not avaiable
Where do you get this error exactly ?
Try to enable the debugger - and step tru your code untill you get the error.
cheers,
Tom
Try to enable the debugger - and step tru your code untill you get the error.
cheers,
Tom
And I'm guessing you still don't have multiple recipients working. To make that work, in your dialog box form or subfrm, set the field to be multiple valued. Declare RECIPIENT as variant (Dim RECIPIENT As Variant). This will allow the memo's SendTo to accept whatever single or multiple values are entered in the dialog.
As to the Document Command Is Not avaiable, as Tom says, use debugger. There is a debuger bug when using form buttons; put the statement STOP at the top of your script to avoid it.
As to the Document Command Is Not avaiable, as Tom says, use debugger. There is a debuger bug when using form buttons; put the statement STOP at the top of your script to avoid it.
ASKER
OK that fixed the multiple email problem - IT now sends emails to all the names. How do I turn the dugger on?
File/Tools/Debug Lotusscript
cheers,
Tom
cheers,
Tom
ASKER
It WOrks - IT WORKS - YEA!!!!!!!!!! One last question -> Can I put a link to the document in the email it sends
Yes, but you'll need to change the script a bit
instead of
message.Body = COMMENT
put
dim rtitem as notesrichtextitem
set rtitem = message.createrichtextitem ( "Body" )
Call rtitem.AppendDocLink( uidoc.document , "link to document" )
Call rtitem.AddNewLine(2)
Call rtitem.AppendText( COMMENT )
...
cheers,
Tom
instead of
message.Body = COMMENT
put
dim rtitem as notesrichtextitem
set rtitem = message.createrichtextitem
Call rtitem.AppendDocLink( uidoc.document , "link to document" )
Call rtitem.AddNewLine(2)
Call rtitem.AppendText( COMMENT )
...
cheers,
Tom
ASKER
I am going to create a new question so I can reward more points to people. There is still a error and I will open the other question with it. So look for the new post.
Well the problem is most likely there because you use the QueryClose event to do some uidoc stuff... Right ?
It should be possible to move the code away from the dialogbox , and put that in the main button.
cheers,
Tom
It should be possible to move the code away from the dialogbox , and put that in the main button.
cheers,
Tom