How do I delete the 32k errored document? - lotus-notes

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).

Related

Is there a way to iterate over a NotesDocumentCollection containing a deletion stub using only GetFirst/NextDocument?

I'm working in several scripts iterating responses collections for main documents which get replicated, and I'm hitting a problem.
If I obtain a NotesDocumentCollection which contains one or more deletion stubs, when I iterate with GetNextDocument I get a NotesDocument object which has no attributes (doc.IsValid is False, doc.IsDeleted is True, and accessing any field or property causes an error and the UniversalID is blank). I cannot use this stub to collect the next document in the collection because I get an error that the document is deleted, nor can I remove it from the collection for the same reason.
What can I do to continue the iteration in the existing collection?
I believe there is an isDeleted property you can check before proceeding the document.

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

$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 can I remove few enties in the $UpdatedBy field in a particular documents

With out modifying the option in the database properties Advanced tab Option "Limit entries in $UpdatedBy Fields " --- How can I remove few of the $UpdatedBy field entries in documents.
I have a requirement to remove few of the $UpdatedBy field entities in one particular document.
Any suggestions ?
$ fields are usually maintained by Lotus itself. It is probably not impossible, but this post describe why it is not feasible
If it is absolutely required to do this without changing the database properties, you can consider creating a new document and copy all the items of the previous document (excluding the $ items). This new document will have a new UNID so if any documents are pointing to this document you should fix that also.
It is not possible to edit the $UpdatedBy field.
(see more discussion here)
You could use DXL to export the document without the $UpdatedBy field and then import it back in as a new document. I've used this technique successfully on entire databases where I needed to clear the history from all the documents and from all the database design elements.
The standard NotesDXLExporter NotesDXLImporter help code worked for me, and then I just added a property setting:
exporter.OmitItemNames = "updatedby"
When the documents are reimported, the $UpdatedBy field is recreated, of course, but your name is the only entry.

CouchDB - Auto-increment

In a non-replicate scenario (or one where we have one write master only), would the following work as quick way to give a doc an auto-increment id to small internal customer datbase.
On inserting a new customer query http://couhdb/mydb to get the metadata
Then add doc_count + doc_deleted_count = autoIncId
Set a property on the doc as .oldDbCompatIdThatClientIsUsedTo = auotIncId
This would mean serialize/sync the process of getting the db metadata and writting the doc but thats not a problem given 20 customers added a day etc..
I can think of a couple of ways of doing this:
Create a view that returns max(id) and just assign max(id) + 1 to the new item (there's some chance of collision here though)
Store another document in the database that isn't a normal record but just contains the sequence value. When you want to do a new insert fetch the current value from this doc, add one, save it back to the doc and then if none of that failed use that id for the new record

Resources