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.
Related
I have a lotusscript function that creates new documents containing an attachment in a richtext file.
...
Dim docProcess As NotesDocument
Set docProcess = dbCurrent.createDocument
docProcess.form = "result"
...
'Attach file
Dim rtfFile As NotesRichTextItem
Set rtfFile = docProcess.Createrichtextitem("xmlFile")
Call rtfFile.Embedobject(EMBED_ATTACHMENT, "", filePath + fileName, "file")
Call docProcess.save(False, False)
My form design looks like this
$V2AttachmentOptions is computed for display, value "0"
xmlFile is a (editable) richtext field
However, when opening the document in the Notes client, it looks like this:
We are using Notes V9.01 FP8
How can I hide the attachment displayed below the line?
I found this technote, but that is not related, since I don't open the doc in edit mode (it is created on the server by an agent).
Have you tried not including the fourth parameter? The Designer manual says that it's to be used with OLE/2 objects, not for attachments. The example in the technote contradicts this, but on the other hand I have created many scripts for attachments without the fourth parameter and it's always worked as intended.
I don't seem to find a way to show the ruler when a document is opened in IBM Notes 9.0.1.
I'm using #Command([ViewShowRuler]) in the PostOpen event but it's having no effect.
Putting the command in a button, or in, for example, PostRecalc works fine.
I've read in the Help that this command works in EditMode. The form opens in EditMode by default, but nevertheless, I tried this (in PostOpen) with no useful result:
#Command([EditDocument]; "1");
#UpdateFormulaContext;
#Command([ViewShowRuler])
Any idea or trick how to make this work?
P.S.: The same command when used in PostOpen in Notes 6.5 works well; as expected.
The way I do it is to put some code in the Entering event of the rich text field where I need/want the ruler to be used:
Sub Entering(Source As Field)
Dim ws As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Set uidoc = ws.CurrentDocument
uidoc.Ruler = True
End Sub
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 my Lotus Notes application (classic, not using XPages), the user won't be able to edit documents directly.
Instead, modifications will happen dialog-based and triggered through actions on the form.
For example, I have an action invoking code similar to the following:
Dim ws As New NotesUIWorkspace
Dim result As String
Dim document As NotesDocument
Dim options(1 To 6) As String
'... - Fill options
Set document = ws.CurrentDocument.Document
result = ws.Prompt(PROMPT_OKCANCELCOMBO, "New Value", "Please choose the new value", document.Foo(0), options)
If result <> "" Then
document.Foo = result
Call document.ComputeWithForm(False, True)
Call document.Save(True, False)
End If
This updates the value of Foo to the value the user chose in the dialog.
However, this new value is not shown to the user - the Form does not seem to be refreshed.
Reopening and closing the form does show the new value; it definitely gets updated.
The nearest I could get was the following code (inside the if-block):
ws.CurrentDocument.EditMode = True
document.Foo = result
Call ws.CurrentDocument.Save()
ws.CurrentDocument.EditMode = False
Nevertheless, this solution seems a bit suboptimal to me as I have to enter edit mode.
How can I refresh the form using Notes Script to reflect the change of the field without having to enter edit-mode?
Methods like ws.CurrentDocument.Refresh either don't show any effect or raise errors as they can't be used outside edit-mode.
Many thanks in advance for your ideas, tips and solutions!
I found another solution avoiding entering edit-mode:
As the documentation to Reload states:
Modifications made to the back-end document outside the current
editing session (for example, by an agent or another user) do not
appear until the document is closed and reopened. You can close and
reopen a front-end document with NotesUIDocument.Close(True) and
NotesUIWorkspace.EditDocument.
Thus, the document can be "refreshed" (with a bit of flickering) using:
Dim ws As New NotesUIWorkspace
Dim document As NotesDocument
Set document = ws.CurrentDocument.Document
'...
Call ws.Currentdocument.Close(True)
Call ws.Editdocument(False, document)
Your answer is the best one. Going into edit mode and either setting the field and saving or simply refreshing the page after you've already set the field is the right idea. It's unfortunate but necessary.
The user will need edit rights to the document of course which presents another problem. How do you prevent the user from typing control E or clicking a smart icon to edit the document?
For that you can set a Global variable that controls access to editing the document. When you're opening your dialog you can set that global variable to true and then set it back to false after you've made your changes. In the query mode changed event set continue to the value of that global variable.
If your user has editor rights in that document, you are not able to stop him to bypass any script action in your form and simply edit it.
Better way to let user edit only particular fields is Controlled Access Section.
Lets say you have a table. You want to show the next row to add an order item or something:
#setfield("NumOrders";NumOrders+1);
#Command( [ViewRefreshFields] )
You need a hidden field NumOrders, then refresh will work.
#Command( [ViewRefreshFields] )
It's that easy!