irene79
asked on
Re: Creating and Displaying new notes document from another database
Hi,
I have a mail database and I will like to take some details and assigned it to a new document from another database.
Upon clicking that agent, a new document from another database will be opened and the fields will be populated with the fields from the mail database.
Fields needed are:
- Channel (by default set to "Email")
- Source (by default as "Public")
- email address (Sender of the email)
- Email subject (Subject of the email)
- Date and Time Received (Date and Time the email is received.)
The new document will be populated with the above value. The user will then fill up the rest of the details and then click on the save button to generate the case id.
Can anyone provide me with the code? Thanks!
I have a mail database and I will like to take some details and assigned it to a new document from another database.
Upon clicking that agent, a new document from another database will be opened and the fields will be populated with the fields from the mail database.
Fields needed are:
- Channel (by default set to "Email")
- Source (by default as "Public")
- email address (Sender of the email)
- Email subject (Subject of the email)
- Date and Time Received (Date and Time the email is received.)
The new document will be populated with the above value. The user will then fill up the rest of the details and then click on the save button to generate the case id.
Can anyone provide me with the code? Thanks!
Why not copy/paste a mail in the other database? And an agent triggered on When documents have been pasted, which modifies the document the way you want it?
Assuming your document is open (ie. you are reading said email):
Dim session as New NotesSession
Dim ws as NotesUIWorkspace
Dim uidoc as NotesUIDocument
Dim thisDB as NotesDatabase
Dim otherDB as NotesDatabase
Dim newDoc as NotesDocument
Set thisDoc = ws.CurrentDocument.Documen t
Set otherDB = New NotesDatabase("server", "database.nsf")
Set newDoc = otherDB.CreateDocument()
Set uidoc = ws.EditDocument(True, newDoc)
Call uidoc.FieldSetText("Channe l", "Email")
Call uidoc.FieldSetText("Source ", "Public")
Call uidoc.FieldSetText("EmailA ddress", thisDoc.From)
Call uidoc.FieldSetText("EmailS ubject", thisDoc.Subject)
Call uidoc.FieldSetText("Receiv ed", thisDoc.DeliveredDate)
That should do it ...
-- Shane
Dim session as New NotesSession
Dim ws as NotesUIWorkspace
Dim uidoc as NotesUIDocument
Dim thisDB as NotesDatabase
Dim otherDB as NotesDatabase
Dim newDoc as NotesDocument
Set thisDoc = ws.CurrentDocument.Documen
Set otherDB = New NotesDatabase("server", "database.nsf")
Set newDoc = otherDB.CreateDocument()
Set uidoc = ws.EditDocument(True, newDoc)
Call uidoc.FieldSetText("Channe
Call uidoc.FieldSetText("Source
Call uidoc.FieldSetText("EmailA
Call uidoc.FieldSetText("EmailS
Call uidoc.FieldSetText("Receiv
That should do it ...
-- Shane
Some minor alterations:
Dim session As New NotesSession
Dim ws As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim thisDB As NotesDatabase
Dim otherDB As NotesDatabase
Dim newDoc As NotesDocument
Set thisDoc = ws.CurrentDocument.Documen t
Set otherDB = New NotesDatabase("", "test.nsf")
Set newDoc = otherDB.CreateDocument()
newDoc.Form = "FormName"
Set uidoc = ws.EditDocument(True, newDoc)
Call uidoc.FieldSetText("Channe l", "Email")
Call uidoc.FieldSetText("Source ", "Public")
Call uidoc.FieldSetText("EmailA ddress", thisDoc.From(0))
Call uidoc.FieldSetText("EmailS ubject", thisDoc.Subject(0))
Call uidoc.FieldSetText("Receiv ed", Cstr(thisDoc.DeliveredDate (0)))
Dim session As New NotesSession
Dim ws As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim thisDB As NotesDatabase
Dim otherDB As NotesDatabase
Dim newDoc As NotesDocument
Set thisDoc = ws.CurrentDocument.Documen
Set otherDB = New NotesDatabase("", "test.nsf")
Set newDoc = otherDB.CreateDocument()
newDoc.Form = "FormName"
Set uidoc = ws.EditDocument(True, newDoc)
Call uidoc.FieldSetText("Channe
Call uidoc.FieldSetText("Source
Call uidoc.FieldSetText("EmailA
Call uidoc.FieldSetText("EmailS
Call uidoc.FieldSetText("Receiv
ASKER
Hi,
Can I include the doc link of the email to the newDoc? Can I search and open an document from otherDB based on the subject title? E.g. if subject has case id of XXXX, the agent will search and open document with case id XXXX. Thanks!
Can I include the doc link of the email to the newDoc? Can I search and open an document from otherDB based on the subject title? E.g. if subject has case id of XXXX, the agent will search and open document with case id XXXX. Thanks!
1) Yes, you can, but if the mail is in your database, then the doclink would be to your database, so the intented reader must have Read access to your mail database.
2) Yes, but it's better to store a key, e.g. a keyfield with a name or the document's universal id. They you either have the possibilitiy to open a view and use the keyfield as key, or search directly for the universal id. A link with a universal id will get broken when a document is copied and pasted, whereafter the original is deleted.
2) Yes, but it's better to store a key, e.g. a keyfield with a name or the document's universal id. They you either have the possibilitiy to open a view and use the keyfield as key, or search directly for the universal id. A link with a universal id will get broken when a document is copied and pasted, whereafter the original is deleted.
ASKER
the email is a generic email account shared by a few users, so they should have no problem accessing that mail in the mail database.
can you provide me with the code for the above?
can you provide me with the code for the above?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
yupz i managed to get the doc link after i save the document. otherwise, it just wouldn't appear. if i go to debug mode, the link appears. If i let it run, the link will not appear.
How about the code for searching and opening an document from otherDB based on the subject title? E.g. if subject has case id of XXXX, the agent will search and open document with case id XXXX.
Thanks!
How about the code for searching and opening an document from otherDB based on the subject title? E.g. if subject has case id of XXXX, the agent will search and open document with case id XXXX.
Thanks!
Just build a view in otherDB sorted by CaseID and use view.GetdocumentByKey($cas eID). Are you able to assign CaseID when these are created in otherDB, or would it just be embedded in the subject line? If it's a standard subject line, you could extract and assign them automatically when the case is created from the email.
What is your specific situation (details/examples, please)?
What is your specific situation (details/examples, please)?
ASKER
Case id is already created when the doc is saved. Right now, I need to get the case ID out of the subject field and open the document with that case id.
e.g. subject is "My case no. is FB20050519-1 for followup action"
Upon clicking of the agent, i should be able to extract FB20050519-1 and open this document from another database. How to derive FB20050519-1 .. Based on the "FB20" and a space, i will determine what is the case id. and open this document.
Thanks!
e.g. subject is "My case no. is FB20050519-1 for followup action"
Upon clicking of the agent, i should be able to extract FB20050519-1 and open this document from another database. How to derive FB20050519-1 .. Based on the "FB20" and a space, i will determine what is the case id. and open this document.
Thanks!
Wouldn't it have been a lot easier to have added a CaseID field? It might even be better to correct your database design immediately, by adding the CaseID-field and running an agent that will generate the CaseID-field in existing document, extracting them from the Subject-field. You will absolutely regret it later if you don't correct it now.
How to extract the case-id? That depends. Is the structure of Subject always the same, does it always begin with "My case no. is" and end with " for followup action"? Then its easy:
cid:= @Left(@Right(subject; "My case no. is "); " for followup action")
How to extract the case-id? That depends. Is the structure of Subject always the same, does it always begin with "My case no. is" and end with " for followup action"? Then its easy:
cid:= @Left(@Right(subject; "My case no. is "); " for followup action")
ASKER
If i assign the case id when they create the document and they dun save the document, i will have missing numbers because the numbers assigned wasn't used.
There is no standard for subject. It can start and end with anything. As long as it consist of a case id in the subject, the code should be able to extract the id and open the document in edit mode.
I have already written codes to extract the case id, but im not sure how to open the document in the other database (OtherDB) in edit mode.
Set thisDoc = ws.CurrentDocument.Documen t
Set otherDB = New NotesDatabase("Server", "Test.nsf")
positionOfChar = Instr(thisDoc.Subject(0), "FB20")
subj = thisDoc.Subject(0)
CaseID = Mid(thisDoc.Subject(0), positionOfChar)
positionOfChar2 = Instr(thisDoc.Subject(0), " ")
CaseID = Strleft( CaseID, " ", 5)
There is no standard for subject. It can start and end with anything. As long as it consist of a case id in the subject, the code should be able to extract the id and open the document in edit mode.
I have already written codes to extract the case id, but im not sure how to open the document in the other database (OtherDB) in edit mode.
Set thisDoc = ws.CurrentDocument.Documen
Set otherDB = New NotesDatabase("Server", "Test.nsf")
positionOfChar = Instr(thisDoc.Subject(0), "FB20")
subj = thisDoc.Subject(0)
CaseID = Mid(thisDoc.Subject(0), positionOfChar)
positionOfChar2 = Instr(thisDoc.Subject(0), " ")
CaseID = Strleft( CaseID, " ", 5)
>If i assign the case id when they create the document and they dun save the document,
> i will have missing numbers because the numbers assigned wasn't used.
Then assign a case number during the QuerySave, for it is executed just before the document is saved.
> ... but im not sure how to open the document in the other database (OtherDB) in edit mode
Various posts above describe how to do that. See html:Q_21410504.html#13966 408 in this question.
> i will have missing numbers because the numbers assigned wasn't used.
Then assign a case number during the QuerySave, for it is executed just before the document is saved.
> ... but im not sure how to open the document in the other database (OtherDB) in edit mode
Various posts above describe how to do that. See html:Q_21410504.html#13966
ASKER
yes, the case id is created when the user click on the Save button.
The various post is creating a document in the other database. How about opening the document from the other database?
Set view = otherDB.GetView( "ByCaseID" )
Set newDoc = view.GetdocumentByKey(case ID)
How do I open this document in edit mode? Thanks!
The various post is creating a document in the other database. How about opening the document from the other database?
Set view = otherDB.GetView( "ByCaseID" )
Set newDoc = view.GetdocumentByKey(case
How do I open this document in edit mode? Thanks!
ASKER
oopz saw it already.
Set uidoc = ws.EditDocument(True, newDoc)
Call uidoc.FieldSetText("Contri _Name", "testing")
Set uidoc = ws.EditDocument(True, newDoc)
Call uidoc.FieldSetText("Contri
> yes, the case id is created when the user click on the Save button
That's not exactly what I meant. If you have code in the Save-button on the screen, and then you call save, the user can still cancel the save. That's why you need to put the generation of the case-id in the QuerySave script, because that cannot (or is very hard to) be interrupted.
As I said, I dislike the FieldSetText calls. I prefer to work with the doc (not uidoc), that's why I always try to prepare the doc before I call EditDocument. In this case:
Call newDoc.ReplaceItemValue("C ontri_Name ", "testing")
Place it BEFORE the call to EditDocument.
And thanks :)
That's not exactly what I meant. If you have code in the Save-button on the screen, and then you call save, the user can still cancel the save. That's why you need to put the generation of the case-id in the QuerySave script, because that cannot (or is very hard to) be interrupted.
As I said, I dislike the FieldSetText calls. I prefer to work with the doc (not uidoc), that's why I always try to prepare the doc before I call EditDocument. In this case:
Call newDoc.ReplaceItemValue("C
Place it BEFORE the call to EditDocument.
And thanks :)