{"id":147,"date":"2010-04-13T18:36:00","date_gmt":"2010-04-13T15:36:00","guid":{"rendered":"http:\/\/www.bestcoder.net\/?p=147"},"modified":"2010-05-06T16:34:29","modified_gmt":"2010-05-06T13:34:29","slug":"create-missing-cover-document-using-binder-document-cover-document-which-has-same-job-activity","status":"publish","type":"post","link":"http:\/\/www.bestcoder.net\/?p=147","title":{"rendered":"Create Missing Cover Document using Binder Document &amp; Cover Document which has same Job &amp; Activity"},"content":{"rendered":"<p>Hello,<\/p>\n<p>I made a mistake when i was working on my lotus workflow application. I deleted 9 documents\u2019 cover document \ud83d\ude42<\/p>\n<p>I created a script to solve this problem and want to share with the world.<\/p>\n<p><!--more--><\/p>\n<p>Create an agent \u2013&gt; Trigger : On Event \/ Action Menu Selection , Target : All Selected Documents<\/p>\n<pre class=\"brush: vb;\">Sub Initialize()\r\n\r\n\tDim oWorkspace As New NotesUIWorkspace\r\n\tDim oSession As New NotesSession\r\n\tDim oDatabase As NotesDatabase\r\n\tDim oCollection As NotesDocumentCollection, oCoverCollection As NotesDocumentCollection\r\n\tDim oSelectedDoc As NotesDocument\r\n\tDim oOriginalCoverDoc As NotesDocument\r\n\tDim oNewCoverDoc As NotesDocument\r\n\r\n\t' Authorization Check\r\n\tDim v1 As Variant\r\n\r\n\tv1 = Evaluate ( {@If ( \"[NotesDesigner]\" *= @UserRoles; 1; 0 )})\r\n\r\n\tIf v1 ( 0 ) = 0 Then\r\n\t\tMessageBox \"You are not authorized  !\", 48, \"Attention !\"\r\n\t\tExit Sub\r\n\tEnd If\r\n\t' Authorization Check\r\n\r\n\tSet oDatabase = oSession.CurrentDatabase\r\n\tSet oCollection = oDatabase.UnprocessedDocuments\r\n\r\n\t' Kontrol\r\n\tIf oCollection.Count = 0 Then Exit Sub\r\n\r\n\t' Kontrol\r\n\tIf oCollection.Count &gt; 1 Then\r\n\t\tMessageBox \"Please select only 1 (one) Binder Document !\", 48, \"Attention !\"\r\n\t\tExit Sub\r\n\tEnd If\r\n\r\n\t' Get Binder Document which has missing cover document\r\n\tSet oSelectedDoc = oCollection.GetFirstDocument\r\n\r\n\t' YOUR_VIEW -&gt; You can create a view which can contains original binder &amp; cover document (to be source) and binder document which has missing cover document\r\n\tConst VIEWALIAS = \"YOUR_VIEW\"\r\n\tConst TITLE = \"Cover Document Selection - to be Copied\"\r\n\tConst PROMPT = \"Select an original cover document to be copied !\"\r\n\r\n\tSet oCoverCollection = oWorkspace.PickListCollection ( 1, False, oDatabase.Server, oDatabase.FilePath, VIEWALIAS, TITLE, PROMPT )\r\n\tIf oCoverCollection.Count = 0 Then\r\n\t\tMessageBox \"You have to select a cover document !\", 48, \"Attention !\"\r\n\t\tExit Sub\r\n\tEnd If\r\n\r\n\tSet oOriginalCoverDoc = oCoverCollection.GetFirstDocument\r\n\r\n\tIf oOriginalCoverDoc.Getitemvalue ( \"ACTIVITYIDOS\" ) ( 0 ) &lt;&gt; oSelectedDoc.Getitemvalue ( \"ACTIVITYIDOS\" ) ( 0 ) Then\r\n\t\tMessageBox \"ACTIVITYIDOS has to be same betweeen selected binder document &amp; selected cover document which'll be copied. !\", 48, \"Error !\"\r\n\t\tExit Sub\r\n\tEnd If\r\n\r\n\tSet oNewCoverDoc = oOriginalCoverDoc.Copytodatabase ( oDatabase )\r\n\r\n\t' InstanceOS\r\n\toNewCoverDoc.Replaceitemvalue \"InstanceOS\", oSelectedDoc.Getitemvalue ( \"InstanceOS\" ) ( 0 )\r\n\r\n\t' BinderDocIDOS\r\n\toNewCoverDoc.Replaceitemvalue \"BinderDocIDOS\", oSelectedDoc.Universalid\r\n\toSelectedDoc.Replaceitemvalue \"BinderDocIDOS\", oSelectedDoc.Universalid\r\n\r\n\t' FolderIDOS\r\n\toNewCoverDoc.Replaceitemvalue \"FolderIDOS\", oNewCoverDoc.Universalid\r\n\toSelectedDoc.Replaceitemvalue \"FolderIDOS\", oNewCoverDoc.Universalid\r\n\r\n\t' INSTANCEIDOS\r\n\toNewCoverDoc.Replaceitemvalue \"INSTANCEIDOS\", oNewCoverDoc.Universalid + \"FirstHost\"\r\n\toSelectedDoc.Replaceitemvalue \"INSTANCEIDOS\", oNewCoverDoc.Universalid + \"FirstHost\"\r\n\r\n\t' JOINDOCIDOS\r\n\toNewCoverDoc.Replaceitemvalue \"JOINDOCIDOS\", oSelectedDoc.Getitemvalue ( \"ACTIVITYIDOS\" ) ( 0 ) + oSelectedDoc.Getitemvalue ( \"INSTANCEIDOS\" ) ( 0 ) + oNewCoverDoc.Universalid\r\n\toSelectedDoc.Replaceitemvalue \"JOINDOCIDOS\", oSelectedDoc.Getitemvalue ( \"ACTIVITYIDOS\" ) ( 0 ) + oSelectedDoc.Getitemvalue ( \"INSTANCEIDOS\" ) ( 0 ) + oSelectedDoc.Universalid\r\n\r\n\t' MainDocIDOS\r\n\toNewCoverDoc.Replaceitemvalue \"MainDocIDOS\", oSelectedDoc.Universalid\r\n\r\n\t' SOURCEDOCIDOS\r\n\toNewCoverDoc.Replaceitemvalue \"SOURCEDOCIDOS\", oNewCoverDoc.Universalid\r\n\toSelectedDoc.Replaceitemvalue \"SOURCEDOCIDOS\", oSelectedDoc.Universalid\r\n\r\n\tCall oNewCoverDoc.Save ( True, False )\r\n\tCall oSelectedDoc.Save ( True, False )\r\n\r\n\tMessagebox \"Done !\"\r\n\r\nEnd Sub<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Hello, I made a mistake when i was working on my lotus workflow application. I deleted 9 documents\u2019 cover document \ud83d\ude42 I created a script to solve this problem and want to share with the world.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,3],"tags":[11,12,13],"class_list":["post-147","post","type-post","status-publish","format-standard","hentry","category-development","category-lotusnotesdevelopment","tag-lotus-workflow","tag-lotusscript","tag-missing-cover","entry","has-more-link"],"_links":{"self":[{"href":"http:\/\/www.bestcoder.net\/index.php?rest_route=\/wp\/v2\/posts\/147","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.bestcoder.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.bestcoder.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.bestcoder.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.bestcoder.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=147"}],"version-history":[{"count":2,"href":"http:\/\/www.bestcoder.net\/index.php?rest_route=\/wp\/v2\/posts\/147\/revisions"}],"predecessor-version":[{"id":166,"href":"http:\/\/www.bestcoder.net\/index.php?rest_route=\/wp\/v2\/posts\/147\/revisions\/166"}],"wp:attachment":[{"href":"http:\/\/www.bestcoder.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=147"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.bestcoder.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=147"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.bestcoder.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=147"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}