I'm currently developing a small web-frontend for a old notesdatabase with XPages.
In most of the documents are DWG- and PDF-Files in multiple RTfields, which the user should be able to download via the web-frontend. Since the files are spread between 10-12 RTfields, having a filedownload-control for every field seems to be a bad solution. So i tried merging multiple fields into one via SSJS and provided this as the datasource for the filedownload-control.
<xp:fileDownload
rows="30"
id="fileDownload2"
displayLastModified="false"
displaySize="true"
displayType="false"
displayCreated="false">
<xp:this.value>
<![CDATA[#{javascript:
var allfiles:lotus.domino.RichTextItem=plan.getDocument().getFirstItem("VPL_datei");
allfiles.appendRTItem(plan.getDocument().getFirstItem("VPL_datei_1"));
allfiles.appendRTItem(plan.getDocument().getFirstItem("PGL_datei"));
allfiles.appendRTItem(plan.getDocument().getFirstItem("Plandatei"));
var file1:com.ibm.xsp.model.domino.wrapped.DominoRichTextItem = new com.ibm.xsp.model.domino.wrapped.DominoRichTextItem(plan, allfiles);
return file1;
}]]>
</xp:this.value>
</xp:fileDownload>
But this only gets the attachments from the first field "VPL_datei" and igonores all attachments in the other fields.
Is there any way to merge the fields or provide multiple fields as the datasource? I must not edit the notesdocument or its form.
Merging RTItems on the fly is not possible this way. You have to save the item first...
But you can create your own "FileDownload"-Control.
Using Domino URLs to access attachments
To access a file attachment using a Domino URL, you must know the view name, the document name, and the file attachment name. Domino generates an URL for file attachments when it saves the documents to which the files are attached. These URLs end with the file name of the attachment.
Syntax:
http://Host/DatabaseName/View/DocumentName/$File/fileattachmentname
Where View is either the view name or the view ID, and DocumentName is the document name or ID. $File is a special identifier that indicates an attachment on a document. Fileattachmentname is the file name of the attachment.
Examples:
http://www.acme.com/products.nsf/Documents/$File/Spec_sheet.pdf
Related
Can I add hidden metadata on the document level like you can through the API? In the DocuSign API, I can do the following in the document object:
new Document()
{
DocumentId = (i+1).ToString(),
DocumentBase64 = Convert.ToBase64String(request.Documents[i].Stream.ReadAsBytes()),
Name = request.Documents[i].Name,
DocumentFields = new List<NameValue>()
{
new NameValue()
{
Name = "DocumentType",
Value = "ElectronicConsent"
}
}
};
The DocumentFields specifies what that document is. Through the API, I can retrieve the document and its field:
EnvelopeDocumentsResult docList = envApi.ListDocuments(_accountId, envelopeId);
DocumentFieldsInformation docInfo = envApi.ListDocumentFields(_accountId, envelopeId, document.DocumentId);
Since I know what the returned document is, I can now run business logic on it. I'd like to allow users the ability to perform a similar action in the UI. This would allow the API to retrieve an envelope that did not originate in code, but the code still knows how to handle that type of document.
I tried the following:
I created a "Document Custom Field."
The "Document Custom Field" is of type "Drop Down" and contains various known document types.
I modify the custom field so that it is white and read only (the signer won't be able to modify it).
Before sending the envelope/document, I add this custom field to the form and select the correct document type.
I send the document.
When I run the same API method to retrieve "Document Fields," the value doesn't get returned. It appears that manually placing the field on the document results in the field being part of the "form" instead of metadata.
You cannot set Document Field as you can set it in an API. The Document Custom Field which you are setting is just another reusable DocuSign tab. So on WEBApp if you are planning to use Document Custom Fields, then your Connect listener should check for two things, one document fields which will be coming from the API, and the Document Custom Field which will be coming as form data. When doing through WebApp, I will make that field white label on white text so that it is not visible to the customer, but it is present on the document. To make maintenance easier on your side, I would create two Connect listener, one just for API user who will be using Document Field, another for non-API/WebApp user who will be using these reusable Document Custom Fields, and write different logic on both listener.
I am maintaining an XPage application that has started creating multiple replication or save conflict documents BEFORE the initial document is saved. How can this be happening and how can it be prevented?
Users create a Contract in XPages application and have not yet saved the document so no other user should be able to see it, but when they save anything from 3 to 10 duplicates are created. It also appears to happen at random, that is at random times for random users. When I go into the core Notes database I can see them in an example shown below.
Here is the only refernce to a document datasource I can find.
<xp:this.data>
<xp:dominoDocument var="document1" formName="Contract" computeWithForm="both">
<xp:this.postSaveDocument>
...........
</xp:this.postSaveDocument>
</xp:dominoDocument>
</xp:this.data>
The most typical way multiple save conflicts are created for new documents is if the XPage has multiple dominoDocument datasources on the page and using a Button of type Submit or using the Save Data Sources simple action.
If datasources do not have ignoreRequestParams="true", all data sources are editing the same document, regardless of any other properties defined for the individual datasources.
The Save Data Sources simple action, as its name implies, saves all datasources on the page. However, a button of type Submit will submit the form, which tells the server to also save all datasources, not necessarily restrict functionality to any SSJS defined in the event.
I have an old Notes Client application. On the form are two RichText fields that hold attachments. JPG's, PDF's, whatever. The document also contains a unique key and other meta-data.
What I want to do is migrate from having multiple attachments on a document to a new document for each attachment. I've never done much with embedded objects and even less with MIME.
I'm currently working in XPages Java but could go to LotusScript if need be.
I was working with this snippet:
List<EmbeddedObject> docPicture = this.getFileAttachments(doc, "picture");
List<EmbeddedObject> docPDF = this.getFileAttachments(doc, "pdf");
for (EmbeddedObject eoPic : docPicture) {
picCount++;
Document newDoc = currentDatabase.createDocument();
newDoc.replaceItemValue("form", "fm_file");
newDoc.replaceItemValue("uploadToken", doc.getItemValueString("barCodeHuman"));
newDoc.replaceItemValue("fileName", eoPic.getName());
newDoc.replaceItemValue("size", eoPic.getFileSize());
fileName = eoPic.getName();
fileType = fileName.substring(fileName.length() - 3);
newDoc.replaceItemValue("type", this.getMIMEType(fileType));
// Extract Attachment and Add To Attachment Document
InputStream attachInputStream = eoPic.getInputStream();
Stream attachStream = session.createStream();
attachStream.setContents(attachInputStream);
MIMEEntity attachField = newDoc.createMIMEEntity("attachment");
MIMEHeader attachHeader = attachField.createHeader("content-disposition");
attachHeader.setHeaderVal("attachment;filename=\"" + eoPic.getName() + "\"");
attachField.setContentFromBytes(attachStream, this.getMIMEType(fileType), MIMEEntity.ENC_IDENTITY_BINARY);
Note I'm using the OpenNTF API but could go back to the lotus objects if need be.
Anyway - this almost worked. I got my documents - 1 per attachment. But when going into the field "attachment" in the document propertied it's not a RichTextField it's a MIME something. that's causing me probably with the next phase of my project. The RichTextDocuments work fine but not the MIME ones.
this is a 1 time migration need so any thoughts on how I can end up with RichTextFields would be appreciated. Thanks!!
try to not involve mime entities at all.
as Oliver said, check your target richText field on the form does not have the 'store contents as mime' checked.
you could even use a richText lite field and restrict it to attachments.
I think you might be using the MIMEEntity method setContentsFromStream because you want to directly move the attachment from doc to doc?
if you want to move using just RichText embedded objects (no mime entity involvement) you need to extract the embeddedObject using .extractFile to the file system first.
Then using the RichTextItem that you create on the new doc (instead of create mime entity) you can use rti.embedObject to attach the file you extracted. (probably best to delete the temporary extract file after successful migration), see the designer help for an example of the parameters required for embedding attachments.
when extracting the file to file system you could extract it to the JVM's temporary directory, the file on the file system needs to have the same file name that you want it to have when attached to the new document.
for this reason you can't really use File.createTemporaryFile() because your temp file name will have random characters in it. instead you
you can get the temp directory with
System.getProperty("java.io.tmpdir")`
and the use that in your extract filepath.
another thing to check before starting processing, is the current notesSession's isConvertMIME setting, if to source field is mime, session.isConvertMIME == true will convert the field to richText when loading the doc. I think in xpages it is false by default, though I don't think it will affect you because I think your source attachments are already richText but for someone reading this and using mime source field it would be important to note. also if you change this using setConvertMIME, be sure to change it back to what it was when you finish your processing.
Hello Domino programmers!
I work on a lotus database + xpages and i ran into a following problem:
I have Authors and Readers fields on document and both can contain users and groups.
Both fields are set on XPage using NamePicker control.
When document is saved i would like to hide an "Edit" button when user doesn't have rights to do so.
Is there a way to just check on document, datasource or context - if current user is document author? Or i have to check it all way long, comparing Authors fields - multiple usernames and groups with current username?
Any help will be appreciated.
You can use the Java method NotesContext.isDocEditable(document) to check if user can edit the document.
In SSJS you can do this:
var ctx = com.ibm.domino.xsp.module.nsf.NotesContext.getCurrent();
return ctx.isDocEditable(doc);
This method is also available as an XSnippet.
Throughout my SharePoint site, I have several document repositories that are tied to primary keys from an external database. I have added custom columns in the document library metadata fields so that we will know which SharePoint documents correspond with which table entries. As a requirement, we need to have document uploads that have these fields automatically populated. For instance, I'd like to have the following url:
./Upload.aspx?ClassID=2&SystemID=63
So that when you upload any documents to this library, it automatically adds the ClassID and SystemID values to the corresponding ClassID and SystemID columns outlined in the SharePoint document library fields.
Is there any quick or easy way to do this, or will I have to completely rewrite the Upload.aspx script from scratch?
I think the only way to go is to create your own Upload.aspx page. Read more here.
Unfortunately, it looks like going custom is the only option for now. Here are some tips on how to code the submission page.
There is a corresponding entry that describes how to add a document to a document library here:
How do you upload a file to a document library in sharepoint?
Likewise, once you have a document library file handler, you can alter its metadata column values using this method:
http://www.davehunter.co.uk/Blog/Lists/Posts/Post.aspx?List=f0e16a1a-6fa9-4130-bcab-baeb97ccc4ff&ID=109
Essentially it's just
SPFile.Item["ColumnName"] = "Value";