I need to open a document in an xpage in the browser from a document in the notes client. If I click on the view I open the document in the associated xpage, however in the xpinc client. Is there a way, which is not redirected to the browser from a code in xpage events?
Instead of auto-launching the XPage, open the url via code in your form.
Sub Postopen(Source As Notesuidocument)
Dim ws As New NotesUIWorkspace
Call ws .URLOpen(<computed url to XPAGE>)
source.Close
End Sub
You must do this in Postopen, because URLOpen does not work in the Queryopen.
Related
Should be simple, but IBM doesn't make it easy...
How do I NOT use iNotes when accessing a mail file over HTTP.
I would like to access a custom view and form to my mail file, but I cannot seem to bypass iNotes. The server always gives me an iNotes page instead of my form.
If I use an old mail file template, it will work, but somewhere in the newer mail templates there is a 'switch' that says use iNotes.
Obviously I still want HTTP, just not iNotes on this one mail file -- I do not want to use an old email template. Where is the 'switch?'
Thanks in advance.
You can force the "classic" ui by adding an URL parameter:
hxxp://yourserver.yourdomain.com/mail/mailfile.nsf?OpenDatabase&ui=webmail
Same works for opening a view:
hxxp://yourserver.yourdomain.com/mail/mailfile.nsf/YourView?OpenView&ui=webmail
If you want to completely disable iNotes for a mailfile without URL hacking, then you can delete the "link" to the corresponding FormsX.nsf- File. This link is stored in the database icon. The icon document contains an item called $FormsTemplateFile.
This "context" has been reveiled, when something went wrong with the german templates in R9 that still pointed to Forms85.nsf. Check this link at IBM for details. The code in that link can also be used to solve your problem by removing the "linking" item:
Dim sess As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim item As NotesItem
Dim newFF As String
Dim itemFF As NotesItem
Set db = sess.CurrentDatabase
Dim session As New NotesSession
Dim n As String
Set db = session.CurrentDatabase
n = "FFFF0010"
Set doc = db.GetDocumentByID (n)
' original code from post
'Set itemFF = doc.GetFirstItem("$FormsTemplateFile")
'newFF = Inputbox("Enter new Forms File name", "Change Forms File", itemFF.values(0))
'Set item = doc.ReplaceItemValue("$FormsTemplateFile", newFF)
'new line to fix problem
Call doc.RemoveItem( "$FormsTemplateFile" )
Call doc.save(True,True)
This works, because in every database the Icon has the same fix noteid.
Thanks to Torsten for 2 options.
I may as well describe the solution in detail:
In Domino Designer, open the Icon in the Resources folder for the database.
Click on the Properties tab, select Document IDs, and copy down the Note ID -- in my case the value was 0000011E.
Run the following agent in LotusScript:
Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Dim iconDoc As NotesDocument
Set db = session.CurrentDatabase
'NoteID of icon document from icon properties
Set iconDoc = db.GetDocumentById("11E")
'Delete the field $FormsTemplateFile
Call iconDoc.RemoveItem("$FormsTemplateFile")
Call iconDoc.Save(True, True)
End Sub
This gets the icon design doc by NoteID from which you can modify any of the fields 'hiding' there. Removing $FormsTemplateFile disconnects the mail file from using iNotes. Cheers.
Ok, I have a form that contains several RichTextFields. In the PostOpen event of the form, I am rebuilding several RichTextTables. In addition, I have a button on this form to change some of the information contained in these RichTextTables.
First Case: The first time the document is opened, the RichTextTables do not display. Each time the document is opened thereafter, it displays just fine. I suspect that it is taking an open, a close and another open to display the RichTextTables correctly. I could use some help in getting them to display the first time.
Second Case: The routine that is called in the PostOpen to do this rebuild is also called from a button on the form that allows the user to change the values contained in the RichTextTables. The routine builds these Tables based on the values it fines in views that are defined in the rebuild routine. When this button is used and changes are made, I am refreshing the views that are affected using the NotesView.Refresh routine, then I'm rebuilding the tablses, closing the UI and reopening the UI to display the Tables. Well, this is not working as the changes do not display. In fact, if I close the document and reopen it, the changes still do not display. If I go to the view that was changed and open it in the UI and then go back an open the document, it displays the changes the second time I open it. How do I get this to work without having to open the view in the ui?
Anybody have any suggestions?
MJ
First of all: Without seeing your code it is nearly impossible to help.
I try nevertheless: NotesRichtextitems need to be saved before they can be displayed in frontend. So you need to have a "CloseAndReopen" - Function, that does your updates, saves the backend- document and then reopens the document. Something like this:
'Declare variables
Dim ses As New NotesSession
Dim db As NotesDatabase
Dim ws As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim doc As NotesDocument
Dim body As NotesRichtextitem
Dim strUnid As String
'- Set database to get the document
Set db = ses.CurrentDatabase
'- get the current uidoc
Set uidoc = ws.CurrentDocument
'-save it, otherwise you will not be able to access the richtextitem
If uidoc.IsNewDoc Then Call uidoc.Save()
'- Get The backend document
Set doc = uidoc.Document
'- Get the richtextitem
Set body = doc.GetFirstItem( "Body" )
'- and do something with it
Call body.AppendText( "some very interesting text" )
Call body.AddNewline( 2 )
'- found this useful to make the Richtextitem have the changes directly
Call body.Compact()
'- Save it
Call doc.Save( True, True, True )
'- get the unid to be able to reopen
strUnid = doc.UniversalID
'- Make the "do you want to save" disappear
Call uidoc.Document.ReplaceItemValue( "SaveOptions" , "0" )
'- close it
Call uidoc.Close
'- Destroy the object for the doc (otherwise it might NOT really close)
Delete Doc
'- get it back
Set doc = db.GetDocumentByUNID( strUnid )
'- and reopen
Call ws.EditDocument( False , doc )
For your View- question: NotesView.Refresh does NOT Rebuild the index for the view. It just refreshes your In- Memory- representation with everything that happened since you initialized the object. But probably a "NotesView.AutoUpdate=True" might help. But probably your Server is simply to busy to keep the view index up to date, or the view is not configured to automatically update (check the view properties)...
Again: Without code, this is just blind guessing...
This is very common since R4 (this versions introduced LS): RT updates are reflected only after closing and opening document again. If you alter RT in open document, you need to reopen it.
Simple solution is to use:
unid = ... ' get UNID of current document
workspace.CurrentDocument.Close
workspace.EditDocument unid, False
This will reopen document and you will see changes to RT.
Your document should be saved. And your RichtextItem should be updated. After that only the content of the RichText item will be shown.
Set the SaveOptions field as 0. Save the document.
Update the RichText field.
In lotusscript I usually do the following to create a simple email which contains a link that points to a notes database/view. Is there any way I can modify the link(appenddoclink) so that it opens an xpage? Say my xpage name is "Staff_Page".
Dim maildoc As NotesDocument, rtitem As NotesRichTextItem
Set maildoc=New NotesDocument(db)
maildoc.subject="Email Address(s) For Your Approval"
Set rtitem=New NotesRichTextItem(maildoc, "Body")
Call rtitem.Appendtext("Dear John,")
Call rtitem.Addnewline(2)
Call rtitem.Appenddoclink(db, "", "Click to open the XPage.")
Call maildoc.Send(False, "john#mail.com")
I've looked at the XPages URL Cheat Sheet but those are not lotusscript. I'm doing XPiNC with some lotusscript agent.
Easiest one is to specify in your Form properties "open xpage instead"
Second option is to specify a URL link pointing to it with the href=notes://server/....
You might be better off using mime mail (snippets for that on OpenNTF) since you have easier formatting options
I use the following code to make sure I go back to a particular view when closing a document and select the newly created document:
Dim ws As New NotesUIWorkspace
Dim uidb As NotesUIDatabase
Set uidb = ws.CurrentDatabase
Call uidb.OpenView("vwMyView", , False)
ws.CurrentView.SelectDocument(Source.Document)
If the view is already open then this code will go to the view defined above and select the document. Accordingly if the view is not open, it will open the view and select our document. This is useful when a new document is created and the view index has not yet been updated.
This code works great, but how do I get this code to work, if I have the view as a part of a frame-set which is also set to be the home-page (home tab).
Edited:
Just to explain the issue further, I have a frameset which links to multiple databases, when a user clicks on the outline control to open a link, it opens a view within the frameset. Then when a new document (which belongs to another database compared to where the outline is) is created from this view, we open a new window outside of this frameset. On closing this document, I want to go back to the frameset (which is now in another database compared to this document) and refresh the view to select current newly document in view. This frameset is the Home page in my case.
Check whether SetTargetFrame can do something for you:
Call notesUIWorkspace.SetTargetFrame( frame$ )
Is the view set to auto frame into the frame set?
I want to preview the current form and in the preview I can print it, how can I do this in lotus script?
You want to preview currently selected document in a view?
You could use view action that would run something like this:
Sub Click(Source As Button)
Dim w As New NotesUIWorkspace
Dim doc As NotesDocument
Set doc = GetSelectedDoc()
Call w.DialogBox(doc.form(0),True,True,True,True,False,True,"Put your title here",doc,True,True,False)
End Sub
Function GetSelectedDoc() As NotesDocument
'MbĀ¤, 04.04.2005
'The function returns currently selected document
'On Error Goto ErrHandler
Dim s As New NotesSession
Dim db As NotesDatabase
Dim c As NotesDocumentCollection
Set db = s.CurrentDatabase
Set c = db.UnprocessedDocuments
If c Is Nothing Then Exit Function
Set GetSelectedDoc = c.getFirstdocument
'add your error handling
End Function
See here for NotesUIWorkspace.DialogBox param explanation.
Or you can simply use #DialogBox formula:
#DialogBox( form ; [AUTOHORZFIT] : [AUTOVERTFIT] : [NOCANCEL] : [NONEWFIELDS] : [NOFIELDUPDATE] : [READONLY] : [SIZETOTABLE] : [NOOKCANCEL] : [OKCANCELATBOTTOM] : [NONOTE] ; title )
Notes is not really great for printing. Depending on your requirements you might be better off writing code to create a word document, which can then be printed. There are plenty of examples out there for achieving this and here is one of them to get you started: http://searchdomino.techtarget.com/tip/A-flexible-data-export-agent-for-Lotus-Notes
Hope this helps.
Create a subform with a read-only version of the form you want to print.
To preview the form - have the subform display in a Dialog box. Have dialog box set to inherit the values from main document.
On the subform display a print button that will print the read-only document. Have the print button hide when printed.
Have you tried to do a right click on the document? You might be able to print it by doing a right click. I would try the simple things first and see if this meets the user needs.
If you are talking about a workflow where you are handling documents and the process is complete and you want to preview the final document you should be able to do this via the UI Document Classes in either the java side or the NotesUI classes in LotusScript. Once you have a handle to the UIDocument you can do several things..
I would try setting the document to readonly and show it in the Preview pane if that object is in your UI design. You could then query the user if they want to print the document or not and use the UIDocument.print option.