1

This is a more explicite extension on my previous question.

From an button on an XPage I create a new database

targetDB = dir.createDatabase(fileName);

I then copy a bunch of stuff into the targetDB from the sourceDB. I then want to set the launch properties in the targetDB which is where the problem comes. I know that I can get the iconNote = targetDB.getDocumentByID("FFFF0010") except there is no iconDoc in the target. Does anyone have a way to create this doc with the specific NoteID?

I tried copying the iconNote document from the sourceDB to the targetDB but that does not work. Changes the UNID and noteID. Can't find any database method to create an icon Note.

Found lots of stuff on how to change the settings in the iconNote, but nothing on how to create one if there is not one in the database.

Thanks to Jesse I took his code and changed it to SSJS and it works fine.

var dir:NotesDbDirectory = session.getDbDirectory("Development");
var newDB:NotesDatabase = dir.createDatabase("XPages/install/created.nsf");
var importer:NotesDxlImporter = session.createDxlImporter();
importer.setDesignImportOption(6);
var dxl:String = "<?xml version='1.0'?>\n" +
"<note default='true' class='icon'>\n" +
"   <item name='$TITLE'>\n" +
"       <text>Test Title</text>\n" +
"   </item>\n" +
"   <item name='$Flags'>\n" +
"       <text>J7NZq?!</text>\n" +
"   </item>\n" +
"</note>\n";
importer.importDxl(dxl, newDB);
var iconNote = newDB.getDocumentByID("FFFF0010");
iconNote.replaceItemValue("$DefaultXPage", "xpWFSDemo.xsp");
iconNote.replaceItemValue("$DefaultClientXPage", "xpWFSDemo.xsp");
iconNote.save();
dBar.info(iconNote.getItemValueString("$Flags"));

1 Answer 1

2

Something like this oughta do it:

DbDirectory dir = session.getDbDirectory(null);
Database newDB = dir.createDatabase("tests/created.nsf");
DxlImporter importer = session.createDxlImporter();
importer.setDesignImportOption(DxlImporter.DXLIMPORTOPTION_REPLACE_ELSE_CREATE);
String dxl = "<?xml version='1.0'?>\n" +
"<note default='true' class='icon'>\n" +
"   <item name='$TITLE'>\n" +
"       <text>Some DB Title</text>\n" +
"   </item>\n" +
"   <item name='$Flags'>\n" +
"       <text>J7NZq?!</text>\n" +
"   </item>\n" +
"</note>\n";
importer.importDxl(dxl, newDB);

That's with the two "open XPage" options set already - you could also include the two XPage name items the same way, and it may be a good idea to export the icon note from an existing DB (database.getDocumentByID("FFFF0010").generateXML()) and paste in the actual icon item as well, since this DXL will result in an icon-less database. Nonetheless, it seems to work in my testing as a basis.

And after that point, you'll be able to fetch the icon note using the usual "FFFF0010" pseudo-ID and replace item values the same way I mentioned before.

6
  • Don't forget the ACL Note. Commented May 29, 2014 at 20:28
  • 1
    Also a default view. Actually, the best solution to the whole problem is probably a template DB to be used with Database#createFromTemplate. Though composing a new Notes DB bit by bit is a fun project too. Commented May 29, 2014 at 20:44
  • Instead of importing a single note with DXL you can import a complete (blank) database. This would fit all the requirements. Commented May 29, 2014 at 21:05
  • Jesse - actually you are right a template would be the best solution, but because I can not control the end user environment the template is just not practical. Sven - to do a dxl import of a blank DB there would have to be a blank DB available to import, so we are at the same point as using a template I would guess. Thanks to all - what I have should work and get my job done.
    – Bill F
    Commented May 29, 2014 at 21:51
  • @BillF: No, you can use a hardcoded DXL. A blank database is not required (only once, to generate the DXL). Commented May 30, 2014 at 5:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.