Xiao Lei, software engineer, IBM Xiao Lei, software engineer, responsible for c api development in IBM Lotus Domino toolkit team. Kang Jian, Senior Software Engineer, IBM Kang Jian, Senior Software Engineer, responsible for testing in IBM Lotus Sametime team. Wu Zhonghua, software engineer, IBM Wu Zhonghua, Lotus N/d Mr Team Software Engineer, responsible for testing Lotus Notes.
Introduction:Lotus Notes database is a document-based database. Many attachments (such as Word documents, PDF documents, and Excel documents) are often embedded in rich text fields of documents ). You often need to export these attachments to other systems for use. However, when you need to export attachments in many documents, you can only manually open each document one by one and export the attachments, and then import the attachments to other systems, when the number of attachments is large, the efficiency is greatly reduced. This article analyzes the requirements for batch export of several attachments from the user's perspective and provides corresponding solutions.
Mark this article!
Release date:January 13, 2011
Level:Elementary
Access status1184 views
Suggestion: 0 (Add Comment)
Average score (1 in total)
Introduction
The Notes database is a document-based database. Many attachments (such as Word documents, PDF documents, and Excel documents) are often embedded in rich text fields of documents ). These attachments are often important work materials. Users often need to export these attachments to other systems for processing, as shown in figure 1, you can save the selected attachments or all attachments in this document to the local system. Sometimes you need to export attachments in multiple documents, as shown in Figure 2. Each document is embedded with attachments. You need to export all the attachments in the selected documents. In this case, you can only manually open each document one by one and export the attachments to the local system, and then import the attachments to other systems, which greatly reduces the efficiency. The requirements for batch export of several attachments and corresponding solutions are analyzed below.
Figure 1. Export of attachments in the Notes document
Figure 2. Export of attachments in multiple notes documents
Back to Top
Requirements for batch export of attachments and Their Solutions
1. Export to local system
For example. A company uses an Excel form as the company's report management system. Their business process is: first, the company regularly issues an Excel report template for the company. Then, the grass-roots business personnel should fill in the report regularly at the end of each cycle, that is, fill in data in the template, create a new Notes document, and embed the Excel file into this document for submission. Finally, the company's information collectors need to export Excel files from each Notes document, and then manually summarize and process these reports. Obviously, if the number of business personnel is large, there will be a lot of notes documents, and this method of manually exporting attachments will eventually be overwhelmed. This article develops a savetolocalsystem agentProgramIt can batch export the attachments in the selected documents in the Notes database to the specified system directory. This agent is written in Lotus script. For details, seeCodeListing 1 can also be written using Java APIs. The attachment. nsf in this article contains the savetolocalsystem agent program and test data.
Listing 1. Batch export of attachments in multiple notes documents to the local system
Type browseinfo howner as long pidlroot as long pszdisplayname as string lpsztitle as string ulflags as long lpfn as long lparam as long iimage as long end type const Limit = & H1 const Limit = & H2 const bif_statustext = & H4 const partition = & H8 const bif_browseforcomputer = & h1000 const bif_browseforprinter = & h2000 const max_path = 260 declare function implements lib "shell32" alias "inline" (byval pidl as long, byval pszpath as string) As long declare function shbrowseforfolder lib "shell32" alias "shbrowseforfoldera" (lpbrowseinfo as browseinfo) As long declare sub cotaskmemfree lib "OLE32" (byval PV as long) declare function getasktopwindow lib "USER32" () as long sub initialize () dim session as new notessession dim dB as notesdatabase dim collection as notesdocumentcollection dim doc as notesdocument dim rtitem as variant dim notesitem as notesitem dim bi as browseinfo dim pidl as long dim path as string dim POS integer bi. howner = getdomaintopwindow () Bi. pidlroot = 0 & BI. lpsztitle = "Select Directory to save the attachments" bi. ulflags = bif_returnonlyfsdirs pidl = shbrowseforfolder (BI) Path = space $ (max_path) If shgetpathfromidlist (byval pidl, byval path) Then Pos = instr (path, CHR $(0 )) end if call cotaskmemfree (pidl) set DB = session. currentdatabase set collection = dB. unprocesseddocuments set Doc = collection. getfirstdocument () while not (Doc is nothing) // assume that the attachment is embedded in the body field. Of course, you can loop through all the fields of the document and process the rich text fields, extract the attachment set rtitem = Doc. getfirstitem ("body") if (rtitem. type = richtext) Then forall o in rtitem. embeddedobjects if (O. type = embed_attachment) then call o. extractfile (left (path, pos-1) & "\" & O. name) end if end forall end if set Doc = collection. getnextdocument (DOC) Wend end sub |
Operation instructions: add the savetolocalsystem agent to any Notes database, select the document to export attachments from any view, and click savetolocalsystem in the menu "actions, in this case, a dialog box is displayed to select the storage directory, as shown in 3. Click OK, and the attachments in the selected document will be exported to the selected directory.
Figure 3. Batch export of attachments in multiple notes documents to the local system
2. Summarize to the Notes document
For the above example, the Administrator may also need to summarize the attachments in different documents to a document of the Notes database, or to a document of another database. This article develops another savetonotesdatabase agent, which can create a new document in the specified Notes database and summarize the attachments in the selected document to this document in batches. This agent is also written in Lotus script. For details, see Code List 2. You can also use Java APIs to write the agent. The attachment. nsf in this article contains the savetonotesdatabase agent program and test data.
Listing 2. Batch Summary of attachments in multiple notes documents to the Notes documents
Sub initialize () dim session as new notessession dim dB as notesdatabase dim collection as notesdocumentcollection dim doc as notesdocument dim rtitem as variant dim doc2 as notesdocument dim workflow as comment dim notesitem as notesitem Dim workspace as new comment dim result as variant result = workspace. prompt (13, "Choose database to save the attachments", "") set DB = session. currentdatabase set collection = dB. unprocesseddocuments set Doc = collection. getfirstdocument () If result (0) = "" & Result (1) = dB. filename then set doc2 = dB. createdocument () else dim DB2 as notesdatabase set DB2 = session. getdatabase (result (0), Result (1), false) set doc2 = db2.createdocument () end if // assume that the newly created document is based on the form "main topic ", the attachments are summarized into doc2.form = "main topic" doc2.subject = "new attachment" set notesrichtextitem = new notesrichtextitem (doc2, "body") while not (Doc is nothing) // assume that the attachment is embedded in the body domain. Of course, you can loop through all the fields of the document and process the Rich Text domain to extract the attachment set rtitem = Doc. getfirstitem ("body") if (rtitem. type = richtext) Then forall o in rtitem. embeddedobjects if (O. type = embed_attachment) then call o. extractfile ("C: \ temp \" & O. name) Call notesrichtextitem. embedobject (embed_attachment, "", "C: \ temp \" & O. name) Kill "C: \ temp \" & O. name end if end forall end if set Doc = collection. getnextdocument (DOC) Wend call doc2.save (false, true) end sub |
The operation is similar to the above, but the pop-up dialog box is used to select the storage database. As shown in figure 4, you can select the local Notes database or the Notes database on other servers, after the selection, click "OK". Then, savetonotesdatabase creates a new document in the database and summarizes the attachments in the selected document to this document.
Figure 4. Batch Summary of attachments in multiple notes documents to the Notes documents
3. export to the Lotus quickr site
As a new-generation document collaboration platform, Lotus quickr provides powerful document management functions and provides clients with a series of powerful connectors (connectors ), these connectors can be installed in the form of plug-ins to commonly used desktop applications, so as to achieve access to the document data in the quickr server based on these software. In addition, quickr provides users with a complete set of Document Management APIs for customization and expansion, namely, content public APIs, including WebService APIs and rest APIs.
After the quickr notes connector is installed, you can add the attachments in the Notes database to the quickr site, as shown in 1, which is similar to saving to the local system. If you want to add attachments to multiple documents, you also need to open each document in sequence and add the attachments to a quickr site. Similar to the preceding two cases, you can also develop an agent program to batch add all the attachments in the selected documents to a quickr site. This agent can be compiled using Java API to obtain attachments, And the WebService API can be used to write programs to add the obtained attachments to a place in quickr.
Back to Top
Conclusion
This article describes the requirements for batch export of attachments in the three Notes databases and the corresponding solutions, and provides the specific implementation code for the first two solutions.
In the past two decades, some lotus customers have accumulated a large number of Domino applications, and most of them are running stably. However, with the emergence of emerging technologies, these enterprises urgently need to reuse these existing IT assets to analyze and mine valuable data to the greatest extent possible, it is expected to effectively integrate with other emerging technologies. In addition to the above three requirements, users may also batch import attachments to other systems, such as filenet and some unstructured databases. If you are interested, you can refer to the methods in this article to implement other agents and use the corresponding API to import attachments to other systems in batches.
Back to Top
Download
Description |
Name |
Size |
Download Method |
Example |
Attachment.zip |
597 KB |
HTTP |
Information about the Download Method
References
Learning
- See developerworksArticle: "How to Process Groups in Lotus script ".
- See the developerworks article: "using LotusScript to automatically generate and Operate Excel reports ".
- See the developerworks article "simulate events for custom objects in Lotus script ".
- See the developerworks article "using Lotus script to flexibly operate rich text fields in Lotus Notes ".
Discussion
- Join my developerworks ChineseCommunity.
Author Profile
Xiao Lei, software engineer, is responsible for c api development in IBM Lotus Domino toolkit team.
Kang Jian, Senior Software Engineer, is responsible for testing in the IBM Lotus Sametime team.
Wu Zhonghua, a software engineer of Lotus N/d Mr team, is responsible for testing Lotus Notes.