{"id":379,"date":"2011-11-28T19:31:05","date_gmt":"2011-11-28T17:31:05","guid":{"rendered":"http:\/\/hasselba.ch\/blog\/?p=379"},"modified":"2011-12-04T11:52:52","modified_gmt":"2011-12-04T09:52:52","slug":"quick-n-dirty-leeres-notesdocumentcollection-objekt-instanzieren","status":"publish","type":"post","link":"https:\/\/hasselba.ch\/blog\/?p=379","title":{"rendered":"Quick-n-Dirty: Leeres NotesDocumentCollection-Objekt instanzieren"},"content":{"rendered":"<p><strong>EDIT:<\/strong><\/p>\n<p>Tja, da habe ich wohl nicht aufgepasst! Die Funktionalit\u00e4t gibt es schon:<\/p>\n<pre>database.createDocumentCollection()<\/pre>\n<p>Schade, da\u00df man bei den XSnippets Code nicht mehr entfernen kann.<\/p>\n<p>&nbsp;<\/p>\n<p><del>Domino bietet Out-of-the-Box leider keine M\u00f6glichkeit, ein leeres <em>NotesDocumentCollection-<\/em>Objekt zu instanzieren. Um trotzdem in den Genuss zu kommen, mit einer leeren <em>NotesDocumentCollection<\/em> arbeiten zu k\u00f6nnen, ist der schnellste Weg, einfach alle Dokumente der Datenbank zu verwenden und von sich selbst &#8222;abzuziehen&#8220;.<\/del><\/p>\n<p><del>In SSJS sieht das wie folgt aus:<\/del><\/p>\n<pre><del>\/*****\r\n *** getEmptyDocumentCollection()\r\n\u00a0 *** returns an empty NotesDocumentCollection-Object \u00a0\r\n *****\/\r\n function getEmptyDocumentCollection(){\r\n\u00a0\u00a0\u00a0 var dc:NotesDocumentCollection = null;\r\n\u00a0\u00a0\u00a0 try{\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 dc = database.getAllDocuments();\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 dc.subtract( database.getAllDocuments() );\r\n\u00a0\u00a0\u00a0 }catch(e){}\r\n\u00a0\u00a0\u00a0 return dc; }\r\n\r\n\u00a0\/*** how to use ***\/\r\n\u00a0var hlpDC:NotesDocumentCollection = getEmptyDocumentCollection();\r\n\u00a0var hlpDoc:NotesDocument =\u00a0 database.getAllDocuments().getFirstDocument();\r\n\u00a0hlpDC.addDocument ( hlpDoc )\r\n\u00a0hlpDC.getCount();<\/del><\/pre>\n<p><del>Die gleiche Funktionalit\u00e4t sieht in LotusScript wie folgt aus:<\/del><\/p>\n<pre><del>%REM\r\n Function getEmptyDocumentCollection\r\n\u00a0\u00a0\u00a0 \u00a0Description: Returns an empty document collection\r\n\u00a0\u00a0\u00a0 \u00a0Created Nov 28, 2011 by Sven Hasselbach\r\n\u00a0%END REM\r\n\u00a0Function getEmptyDocumentCollection() As NotesDocumentCollection\r\n\u00a0\u00a0\u00a0 \u00a0 \u00a0\u00a0 \u00a0On Error GoTo errH\r\n\u00a0\u00a0\u00a0 \u00a0 \u00a0\u00a0 \u00a0Dim session As New NotesSession\r\n\u00a0\u00a0\u00a0 \u00a0 \u00a0\u00a0 \u00a0Dim db As NotesDatabase\r\n\u00a0\u00a0\u00a0 \u00a0 \u00a0\u00a0 \u00a0Dim dc As NotesDocumentCollection\r\n\u00a0\u00a0\u00a0 \u00a0 \u00a0\u00a0 \u00a0Set db = session.Currentdatabase\r\n\u00a0\u00a0\u00a0 \u00a0 \u00a0\u00a0 \u00a0Set dc = db.Alldocuments\r\n\u00a0\u00a0\u00a0 \u00a0 \u00a0\u00a0 \u00a0dc.Subtract db.Alldocuments\r\n\u00a0\u00a0\u00a0 \u00a0 \u00a0\u00a0 \u00a0Set getEmptyDocumentCollection = dc\r\n the_end:\r\n\u00a0\u00a0\u00a0 \u00a0 \u00a0\u00a0 \u00a0Exit Function\r\n errH:\r\n\u00a0\u00a0\u00a0 \u00a0 \u00a0\u00a0 \u00a0Print \"getEmptyDocumentCollection() - Error #\" &amp; Err &amp; _ \": '\" &amp; Error &amp; \"' @ Line \" &amp; Erl\r\n Resume the_end\r\n End Function<\/del><\/pre>\n<p><del>Und schon hat man eine leere NotesDocumentCollection, der man nach Belieben arbeiten kann!<\/del><\/p>\n","protected":false},"excerpt":{"rendered":"<p>EDIT: Tja, da habe ich wohl nicht aufgepasst! Die Funktionalit\u00e4t gibt es schon: database.createDocumentCollection() Schade, da\u00df man bei den XSnippets Code nicht mehr entfernen kann. &nbsp; Domino bietet Out-of-the-Box leider keine M\u00f6glichkeit, ein leeres NotesDocumentCollection-Objekt zu instanzieren. Um trotzdem in &hellip; <a href=\"https:\/\/hasselba.ch\/blog\/?p=379\">Weiterlesen <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9,20,76,74],"tags":[7,4,80,5,32,3],"class_list":["post-379","post","type-post","status-publish","format-standard","hentry","category-javascript","category-lotus-script","category-ssjs","category-xpages","tag-domino","tag-js","tag-lotus-script","tag-ssjs","tag-tipp","tag-xpages"],"_links":{"self":[{"href":"https:\/\/hasselba.ch\/blog\/index.php?rest_route=\/wp\/v2\/posts\/379","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hasselba.ch\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hasselba.ch\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hasselba.ch\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/hasselba.ch\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=379"}],"version-history":[{"count":6,"href":"https:\/\/hasselba.ch\/blog\/index.php?rest_route=\/wp\/v2\/posts\/379\/revisions"}],"predecessor-version":[{"id":383,"href":"https:\/\/hasselba.ch\/blog\/index.php?rest_route=\/wp\/v2\/posts\/379\/revisions\/383"}],"wp:attachment":[{"href":"https:\/\/hasselba.ch\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=379"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hasselba.ch\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=379"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hasselba.ch\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=379"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}