I heard that there is a function called NotesJSON **** that can exchange documents in the Notes database in JSON format, so I thought I'd try it ... Since it is a class that can be used from Notes10, I could not verify it in my Notes environment.
However, while searching for help etc., I found that a Notes document can be output in XML format by using a method called generateXML. It seems to be a useful function, but LotusScript cannot be used because it is a function provided only in Java.
When I actually used it, it was a ** amazing feature **. The generateXML class structurally exports all field information and values in a document, but it also accurately exports multiple values in list format and rich text field information.
When writing in LotusScript, after getting the document, get the fields in the document with For All item In doc.Items etc., and get various troublesome codes such as the code to get multiple values for each field. I have to write it as "chima-chima", but if I write it in the generateXML class, it only takes one line ... There is only a little description in the help, but I think it is a feature that needs to be known more.
import lotus.domino.*;
import java.io.*;
public class JavaAgent extends AgentBase {
public void NotesMain() {
try {
Session session = getSession();
AgentContext agentContext = session.getAgentContext();
// (Your code goes here)
Database db = agentContext.getCurrentDatabase();
View view = db.getView("Main");
view.setAutoUpdate(false);
Document tmpdoc;
BufferedWriter bw = new BufferedWriter( new FileWriter("c:\\temp\\document.xml"));
Document doc = view.getFirstDocument();
while (doc != null) {
System.out.println(doc.getItemValueString("Uname"));
doc.generateXML(bw);
tmpdoc = view.getNextDocument(doc);
doc.recycle();
doc = tmpdoc;
}
bw.close();
} catch(Exception e) {
e.printStackTrace();
}
}
}
I created a test form with multiple types such as rich text and list, and confirmed that multiple documents are output in XML format.
I created multiple Notes documents with a test form with various types of fields such as text/rich text/time/checkbox.
<document form='Main'>
<noteinfo noteid='912' unid='C7638A880050D1014925865B001F3A1B' sequence='1'>
<created><datetime>20210112T144104,91+09</datetime></created>
<modified><datetime>20210112T144104,92+09</datetime></modified>
<revised><datetime>20210112T144104,91+09</datetime></revised>
<lastaccessed><datetime>20210112T144104,92+09</datetime></lastaccessed>
<addedtofile><datetime>20210112T144104,92+09</datetime></addedtofile></noteinfo>
<updatedby><name>CN=Taro Yamada/O=Taro Yamada</name></updatedby>
<item name='Uname'><text>Ichiro Yamada</text></item>
<item name='UDate'><datetime>20210201</datetime></item>
<item name='UTimeS'><datetime>T091500,00</datetime></item>
<item name='UTimeE'><datetime>T180000,00</datetime></item>
<item name='Rtxt'><richtext>
<pardef id='1'/>
<par def='1'><run><font size='18pt' style='bold' name='Meiryo' pitch='variable'
truetype='true' familyid='30' color='red'/>Rich text</run></par>
<par def='1'><run><font size='18pt' style='bold' name='Meiryo' pitch='variable'
truetype='true' familyid='30' color='red'/></run></par></richtext></item>
<item name='CheckBox'><textlist><text>Saitama</text><text>Tokyo</text><text>Ibaraki</text></textlist></item>
<item name='Num'><number>12345678.9</number></item></document>
<document form='Main'>
<noteinfo noteid='90e' unid='4358C36AE3645EB44925865B001F2BF9' sequence='1'>
<created><datetime>20210112T144028,73+09</datetime></created>
<modified><datetime>20210112T144028,75+09</datetime></modified>
<revised><datetime>20210112T144028,74+09</datetime></revised>
<lastaccessed><datetime>20210112T144028,75+09</datetime></lastaccessed>
<addedtofile><datetime>20210112T144028,75+09</datetime></addedtofile></noteinfo>
<updatedby><name>CN=Taro Yamada/O=Taro Yamada</name></updatedby>
<item name='Uname'><text>Saburo Yamada</text></item>
<item name='UDate'><datetime>20210112T000000,00+09</datetime></item>
<item name='UTimeS'><datetime>T090000,00</datetime></item>
<item name='UTimeE'><datetime>T180000,00</datetime></item>
<item name='Rtxt'><richtext>
<pardef id='1' keepwithnext='true' keeptogether='true'/>
<par def='1'><run><font name='Meiryo' pitch='variable' truetype='true' familyid='30'/></run></par></richtext></item>
<item name='CheckBox'><text>Tokyo</text></item>
<item name='Num'><number>11</number></item></document>
<document form='Main'>
<noteinfo noteid='906' unid='A871F8B1625F2B0E4925865B001EFFCF' sequence='1'>
<created><datetime>20210112T143835,67+09</datetime></created>
<modified><datetime>20210112T143835,68+09</datetime></modified>
<revised><datetime>20210112T143835,67+09</datetime></revised>
<lastaccessed><datetime>20210112T143835,68+09</datetime></lastaccessed>
<addedtofile><datetime>20210112T143835,68+09</datetime></addedtofile></noteinfo>
<updatedby><name>CN=Taro Yamada/O=Taro Yamada</name></updatedby>
<item name='Uname'><text>Jiro Yamada</text></item>
<item name='UDate'><datetime>20210103T000000,00+09</datetime></item>
<item name='UTimeS'><datetime>T090000,00</datetime></item>
<item name='UTimeE'><datetime>T180000,00</datetime></item>
<item name='Rtxt'><richtext>
<pardef id='1' keepwithnext='true' keeptogether='true'/>
<par def='1'><run><font name='Meiryo' pitch='variable' truetype='true' familyid='30'/>Ah ah</run></par></richtext></item>
<item name='CheckBox'><text/></item>
<item name='Num'><text/></item></document>
Recommended Posts