1
votes

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

1 Answers

2
votes

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.