Way to convert NotesDocument to NotesXspDocument - xpages

I would like to know whether there is a way to convert Notesdocument to notesxspdocument.
or is there a way to know that notesdocument is in edit mode from serverside javascript agent?
thank for your help.

You can use the wrapDocument XSnippet to convert a NotesDocument into a NotesXspDocument.

Related

Modifying an url in a MIME field

I have a Notes document with a field BodyMime where the Store content as HMTL/MIME is set.
In that field, I have some notes URL : Notes://ServerNameA/DB.
I need to replace all the occurrences in the MIME field to put Notes://ServerNameB/DB.
I tried TeamStudio Configurator , he is able to do the change but I am losing all CSS and Format.
Anybody who have an idea what I can do ?
Some Example ?
Thanks a lot
You can try Genii Software MidasLSX. It's a commercial product.
If you don't want to spend any money, you can use NotesDXLExporter and NotesDXLImporter classes to export, replace, and import back the documents.
You can write a LotusScript agent to process each document, use
Session.ConvertMIME = False
before you get the NotesDocument. This prevents the loss of formatting as there is no conversion to RichText.
You can then
Set mime = NotesDocument.GetMIMEEntity
then iterate through the Mime.ChildEntities
Set child = mime.GetFirstChildEntity
While Not(child Is Nothing)
then use DecodeContent or create a NotesSession.CreateStream and use mime.GetContentAsText(stream)
eg
Call child.DecodeContent
You can then search and replace in the child.ContentAsText and re-encode the mime-entity.
Call child.EncodeContent(ENC_QUOTED_PRINTABLE) ' (1762) or use any other encoding scheme.
Set child = child.GetNextSibling
Wend ' iterate through all mime-entities
finally remember to save your NotesDocument

Is there a way to store a new Agent property with LotusScript?

Folks,
I've got an Agent in Notes using Lotusscript that asks for a directory each time it's invoked. I'd like to store the directory selection so that it doesn't have to be prompted for each time, simply confirmed. But how do I go about storing a permanent reference I can pick up the next time the Agent runs?
Thanks,
KWL
I'm not completely sure what you are asking, but I think a profile document is what you need.
Follow these steps to create the form, which should include a field that contains the value you want to retrieve (for this example we'll call it 'directory') : http://www-12.lotus.com/ldd/doc/domino_notes/Rnext/help6_designer.nsf/b3266a3c17f9bb7085256b870069c0a9/3728634e68f9ca4685256c54004b6c32?OpenDocument
You can access it in your LotusScript function using the NotesDocument class, eg.
dim s as New NotesSession
dim db as NotesDatabase
dim doc as NotesDocument
dim directory as String
Set db = s.CurrentDatabase
set doc = db.GetProfileDocument("DocumentName")
directory = doc.GetItemValue("directory")(0)
You can save the directory selection in an environment string
session.setEnvironmentVar(variablename, value)
http://www-12.lotus.com/ldd/doc/lotusscript/lotusscript.nsf/1efb1287fc7c27388525642e0074f2b6/ceadd0dc386adcbd8525642e00770300?OpenDocument
session.getEnvironmentString(variablename)
http://www-12.lotus.com/ldd/doc/lotusscript/lotusscript.nsf/1efb1287fc7c27388525642e0074f2b6/a2790570da801d6c8525642e0075cdd9?OpenDocument

lotus notes: set numeric field of uidoc document

i have a problem to set numeric field in lotus notes script from uidoc, i have already tried:
call uidoc.fieldsettext("field",value)
but if "field" is numeric field and the value is a number(or a variable containing a number) i can't use fieldsettext method because field is initialized as text and i want numeric.
There is a method like fieldsetnumber or also like it ?
I don't want switch the document from uidoc to doc.
thank's
uidoc.FieldSetText() is the best option and when you save the value will be converted to the appropriate data type, at least according to the documentation.
If using FieldSetText, you have to be careful to format the value in a way that's consistent with the user's preferences and/or the settings of the field (e.g. whether the decimal separator is "," or "."). To avoid this source of error, it's better to use the NotesDocument object for this sort of thing. You need a better reason than "I don't want to," to not do this.
You could use the NotesDocument for this one operation and the NotesUIDocument for everything else, e.g. write:
uidoc.Document.ReplaceItemValue "fieldname", numbervalue
Unless you've deliberately set the option to not reload the UI automatically, this will do what you want. If you have set that option you'll need a second call to do that update.
It's worth remembering that you don't really 'switch' between the NotesUIDocument and NotesDocument - it's the same entity, just with a different set of classes.
The action you want to perform is never going to be 100% reliable with end users being able to change the format of the Date/Time field to suit themselves. Much better interacting with the backend and reloading the UIDoc.
What is the reason you don't want to use NotesDocument?
Nick

$file field in lotus notes document

I am working on Lotus Notes and I have a document that contains multiple files attached to it. Every attached file has a $File field in back end. I need to have attributes of $File field. Please let me know how can I get attributes of $File field of lotus notes document?
You can get that information using the NotesEmbeddedObject class. Here's an example from the docs:
Dim db As NotesDatabase
Dim view As NotesView
Dim doc As NotesDocument
Set db = New NotesDatabase( "SanFrancisco", "hill.nsf" )
Set view = db.GetView( "All Documents" )
Set doc = view.GetLastDocument
Forall o In doc.EmbeddedObjects
Messagebox( o.Name )
End Forall
The NotesEmbeddedObject class has properties you can use or you could presumably extract the file and access it from the file system to get more information.
You don't say which attributes you are after in the $File item. You can obtain some information about each attachment as Ken describes. You can also obtain some (probably less useful) information by iterating to them via the Items collection on a NotesDocument. If information obtained those ways is insufficient, you can get to the $File item directly via calls into the Notes API from LotusScript, but that is much more involved and requires unrestricted execution rights by the signer of the code, or possibly by the user herself, depending on context, I believe.
For more precision, tell us yourself more precisely what you're after. Cheers.

How do you pass a NotesDocument / NotesViewEntry Collection into a Custom Control via custom property?

I want to have a custom control that works on whatever documents I decide to pass to it. What's the best way of doing that?
Assuming that you can't pass the collection directly... should a function be created to convert the collection to a hashMap or vector of UNID's?
Is there another way?
Thanks
If you instead pass a data source, you'll get recycle-safe objects transferred to the Custom Control.
For example, if the XPage defines a document data source, and you pass a reference to that data source to the CC, the Java object being transferred is a DominoDocument, which is a recycle-safe wrapper around the "back end" document. Passing the document directly risks that the linked C object will get orphaned between requests.
Similarly, passing a reference to a view data source provides the CC a DominoView, which is essentially a recycle-safe wrapper around a back end ViewEntryCollection.
For most use cases, you can get away with just passing the back end object directly, but passing the data source is far safer.
Passing NotesDocument and/or NotesDocumentCollection objects to the Custom Control works fine. Just set the Custom Control's property type as java.lang.Object. By this you can transfer what ever objects to the Custom Control.

Resources