Reputation: 27
In my document i have multiple "Body" field which contains Rich-Text data as well as attachment files which is of type (Data Type: MIME Part). My purpose is to only delete the attachment files from my document. I tried this,
if (document1.getAttachmentList("body").isEmpty()) {
requestScope.alist = "No attachments in body";
} else {
document1.removeAllAttachments("body");
document1.save();
requestScope.alist = "All attachments removed from body";
}
where document1 is my data source name, by this code it works properly.
But, i want to retrieve document by
var doc:NotesDocument = database.getDocumentByUNID(context.getUrlParameter("documentId"));
where it does not works. I had even tried by this code,
var doc3:NotesDocument = database.getDocumentByUNID(context.getUrlParameter("documentId"));
var item:NotesItem =doc3.getFirstItem("$FILE");
item.remove();
doc3.save();
But, here problem is that it also deleting rich text data from document.
Is there any other solution can help me out.
Thanks in advance.
Upvotes: 0
Views: 485
Reputation: 2048
What is the difference between the "NotesXspDocument" and "NotesDocument" class in XPages
https://www-10.lotus.com/ldd/ddwiki.nsf/dx/xpages-notesxspdocument-vs-notesdocument.htm
Upvotes: 0
Reputation: 1271
In the first working code you have a the NotesXSPDocument, but in the second example you have the NotesDocument. may be it is an idea to convert the NotesDocument to a NotesXSPDocument so you can use the first example To convert it in SSJS this example may help you https://openntf.org/XSnippets.nsf/snippet.xsp?id=wrap-notesdocument-into-notesxspdocument
Upvotes: 1