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.
Related
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
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
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
I have one page that does a NotesDatabase search and of course returns a collection. I am storing that collection in a sessionScope variable and calling a page where I what ti display the results.
if ( collection1.getCount() == 0)
{
displayErrorMsg("Your search returned zero results. Please try another search.",getClientId("title"), "Zero Results");
}
else
{
sessionScope.put("searchResults",collection1);
var extCont = facesContext.getExternalContext();
extCont.redirect("xp_vwIssueSearchResults.xsp");
}
The page has a data table with the content of the scope variable as it's datasource:
sessionScope.get("searchResults");
When I call this page I get, NotesException: Object has been removed or recycled.
Should I be able to pass a NotesDocumentCollection in a sessionScope variable? I have some thoughts on work arounds but it would sure be nice to pass the NotesDocumentCollection.
You can't keep Notes objects like views, documents, collections for a longer time. In general, you should work with Notes object in a way, that you save the data you're interested in somewhere and recycle (=destroy) the Notes objects right away. The reason is that the Domino server can't save the Notes objects for you between two request because Notes objects aren't serializable (serializable = ability to save objects on disk and restore them back to memory).
In your case, you could save
the search query or
the result values as an Array of Objects (JavaScript) or a List of Maps (Java) or
the documentUniqueIDs of document collection's documents
in your sessionScope variable and use them in your redirected page.
I am having some documents. If I try to open the document then it shows error like "field is too large 32k or view's column & selection formulas are too large"
Whenever I try to delete the document, I am getting the same error. I am not able to delete.
Okay we can try to get the document via backend, But there, I can not get the document handle.
Whatever I try to search then the document collection count is 0.
Important:- I am using Notes 6.5.2.
Thanks in Advance,
You may create new replica of the database, currupted documents won't be copied. Also you may try to use ScanEZ tool from Ytria.
"Okay we can try to get the document via backend, But there, I can not get the document handle."
Could you post the code you are using?
I don't see why the following code would not work:
Dim session As New NotesSession
Dim db As NotesDatabase
Dim col As NotesDocumentCollection
Dim doc As NotesDocument
Dim deleteDoc List as NotesDocument
Set db = session.Currentdatabase
'*** Get collection of selected documents
Set col = db.UnprocessedDocuments
'*** Loop through selected documents
Set doc = col.GetFirstDocument
Do Until doc Is Nothing
'*** Add document to list to delete later
Set deleteDoc(doc.UniversalID) = doc
Set doc = col.GetNextDocument(doc)
Loop
'*** Delete all documents in list from database
ForAll d in deleteDoc
Call d.Remove(True)
End ForAll
Perhaps you may want to change the field that causing you headache to rich text since the limit for rich text field is slightly bigger that normal text field. The limit for rich text filed is limited only by available disk space up to 1GB
Have you tried to simply delete the problem field on a corrupt document, and then delete the document? You can try to do the following:
1- create an agent set to run on selected documents with the following formula:
FIELD corruptfield := #DeleteField;
2 - select a problem document in a view and run the agent
3 - if that does not error out, then try to manually delete the document from the view.
Here is what worked for me :
1/ Get the Note ID of the doc with DocViewer
There may be many other ways to get the NoteID, but it just showed up when I tried to send the doc through DocViewer, the well known free tool
https://www.openntf.org/main.nsf/project.xsp?r=project/Document%20Viewer/summary
2/ Remove the doc with Notes C API
I followed the advice of pstr, and quickly found out this script
http://www.nsftools.com/tips/ApiStublessDelete.lss
Just aim it at the good database, with the Note ID, and it does the trick !!
I tried to change the script in order to not remove the deletion stub (I wished the removal would replicate over my cluster and local replica). But you fall back on the 32k error ! So you have to apply the deletion over every replica (or recreate the replicas of course).