Find dead doc link in Lotus Script - lotus-notes

I have a database and also doc links, I am trying to access those doc link through web. I have found the method appendDocLink in the help. Looked through all the NotesRichTextItem, Document and NotesDocument properties and methods, but there's nothing to check dead link.
What I am trying to do is get all the doclinks in lotus script, and then check to see if they lead to an existing doc or if its a dead link. If yes then will send a mail to the admin about the dead link. All these things I want to happen using a schedule agent.

You need to traverse the NotesRichTextItem using NotesRichTextNavigator and find the elements of type NotesRichTextDocLink.
Dim rti As NotesRichTextItem
Dim rtnav As NotesRichTextNavigator
Dim rtlink As NotesRichTextDocLink
Set rti = doc.GetFirstItem("Body")
Set rtnav = rti.CreateNavigator
If Not rtnav.FindFirstElement(RTELEM_TYPE_DOCLINK) Then
Messagebox "No doclinks in Body item",, "No doclinks"
Exit Sub
End If
Do
Set rtlink = rtnav.GetElement
'Use rtlink.DocUNID to get document UNID and try to fetch the document
Loop While rtnav.FindNextElement
I am not sure whether creating new NotesDocument object from rtlink.DocUNID would result in error or NOTHING (in case document with that UNID is not present). You will have to check that yourself.
The above code snippet has been taken from here and modified for this answer.

Related

can i see lotus notes hidden-document with reader field

in this document, I use reader field to set who can read this document but as first my program is fault that wrong people set in this field and nobody can read this document. I write a code to see all document and that hidden document not show any item.
Set db=session.currentdatabase
Set dc=db.alldocuments
Dim i_count As Integer
For i_count = 1 To dc.Count
Set doccoll = dc.GetNthDocument(i_count)
Next
This is the result
enter image description here
How can I change reader field?
You can enable "Full Access Administration" on administrator client to see all documents in that server.

Lotus Notes Api : On Calendar Entry created/deleted

I'm not familiar with Lotus Notes.
The task is the following: I need to implement the plug in which listen "Calendar Entry created/deleted" event. And send this scheduling (iCal) data to some web service so that it could be synchronized in the another system.
I would appreciate if somebody could give me some vector, where I need to find solution, how to subscribe to such an event?
Thanks
You need to look into agents, specifically the type that runs when documents are created / modified. For deletes look at the QueryDocumentDelete event on the database. Between those two code points you can add the necessary logic to respond to calendar (or other) document creation and deletion.
You'll have to check the documents form to determine if the document being acted upon is a calendar event, but after that it should be straightforward.
Note there can be a delay between when a document is created and when the agent runs.
UPDATE:
Within the agent, you'll need to get the unprocessed documents collection from the database object and operate on that. Using LotusScript it would look like this:
Dim s as New NotesSession
Dim db as NotesDatabase
Dim docCollection as NotesDocumentCollection
Set db = s.CurrentDatabase
Set docCollection = db.UnprocessedDocuments
Then from there you can loop over the document collection and process each NotesDocument object.

Lotus Notes document to PDF

I need some help since I do not know where to start. Ideally, I would like to have a button that can convert my Lotus Notes document to a PDF file, then it will open up a new email then take the email address in that document to the "To" filed. At this point we use CutePDF writer to create the PDF file. I break down the process like the one below:
Print a document
User choose CutePDFwriter
Save the pdf file
Compose a new email with the email address that is on the Notes document placed on the 'To' field
Can anyone help me starting on this?
If you're happy to let the user select cutepdf as the printer, you should be able to get away with using #Commands in a button from the either the document or a view containing the documents (Check the notes designer help).
The only issue I can see is that the user will be able to change the path that cutepdf prints to, so you will have to make the user find the attachment again (but you will be able to automate the attachment dialog coming up).
Got my answer from Domino Designer help file. Use the code below to open up mail file
Dim workspace As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Set uidoc = workspace.CurrentDocument
Dim doc As NotesDocument
Dim item As NotesItem
Set doc = uidoc.Document
Set item = doc.GetFirstItem("QSContactEMail")
Set uidoc = workspace.ComposeDocument _
(mailserver$, mailfile$, "Memo")
Call uidoc.FieldAppendText("EnterSendTo", "Test")
For the printing I just call the print function and let the user choose CutePDF writer

Using VBA to read the metadata or file properties of files in a SharePoint doc library

I have a few hundred Word templates (DOTX) on a SharePoint site. Many teams of users work with these templates.
When a user needs to customize this documentation, they click a special link on SharePoint to generate a new document (DOCX) from the template they choose. This new document file always needs to be "linked" back to its template file on SharePoint. If the document loses that link, it won’t work correctly and is considered “broken”.
When documents break, I need to re-establish the link back to the right template on SharePoint. It makes sense to do this programmatically so I can distribute the solution to my team.
I want to give each template file a unique Template ID (a three-digit number), stored in metadata or a custom file property. When new documents are generated from the templates, the Template ID automatically carries over into the document, so that’s set. Now I just need to use VBA to scan the template files in the SharePoint document library for the matching Template ID. When that’s found, I can re-establish the link and all is well.
I’m basically looking for this:
Sub DocFixer()
Dim objTemplate as Template
Dim objBrokenDoc as Document
Set objBrokenDoc = ActiveDocument
For each objTemplate in "\\SharePoint\Template Library\".Templates
If objTemplate.Properties("Template ID").Value = objBrokenDoc.Properties("Template ID").Value Then
objBrokenDoc.AttachedTemplate = objTemplate.Path
Exit For
End If
Next
End Sub
…but I’m having trouble using VBA to read SharePoint doc library contents without actually opening the contents, as that takes far too long with so many templates, plus its very disruptive for the user.
Any ideas? Could you point me in the right direction?
Edit: Here's my solution:
Sub Macro()
Dim FSO As Object
Set FSO = CreateObject("Scripting.FileSystemObject")
Dim objFile As Object
Dim objDSO As Object
For Each objFile In FSO.GetFolder("\\SharePoint\doc lib\").Files
Set objDSO = CreateObject("DSOFile.OleDocumentProperties")
objDSO.Open objFile.Path
If objDSO.CustomProperties.Item("Template_ID") = ActiveDocument.CustomDocumentProperties("Template_ID").Value Then
ActiveDocument.AttachedTemplate = objFile.Path
End
End If
Next
MsgBox ("No matching template found. Please attach the proper template manually."), vbCritical
End Sub
Apparently this taps into DSOFile.dll (http://technet.microsoft.com/en-us/library/ee692828.aspx), but I didn't have to add the reference? Still confused on that part.
Also, this might not work over https:// (SSL). Worked for me though, so I thought I'd share.
I would start by calling the SharePoint web services from VBA.
Once there you can make a call to GetListItems that will pull back the document with the correct TemplateID attribute directly.

lotus notes automation

Is it possible to automate lotus notes to post a local file to a database? I have a daily task to post a logfile to a notes database. I can gather the logfile via script but don't know enough about notes scripting to figure this out.
I know thrre is a com interface as long as I have the client on the PC, but I can't figure out how to get a file uploaded to a dataase. I can use either vbscript or (preferred) powershell
If you search around the net you'll find examples of using VBScript to manipulate Lotus Notes. Here's one example: http://haveworld.blogspot.com/2006/10/vbscript-and-lotus-notes.html
You'll need to know a little about Lotus Notes to make this work, though. Start small and see if you can even get the Notes Version to appear:
Set oNotesSession = CreateObject("Notes.Notessession") 'create notes session
Msgbox oNotesSession.NotesVersion
If that works, you know you're in good shape. If not, make sure you've installed Lotus Notes correctly and configured it on the client.
The code to post a local file to a database involves connecting to Notes, creating a new Notes Document, adding a file object into the body of the document, and then saving it. You can use any kind of Notes Database to do this, but I'd suggest creating a new one based on the Document Library template, and using that to store your files.
Here is some code that will create a new Notes document, set the subject field, attach a file, and then save the document. This assumes there's a local Notes database already available called "FileStorage.nsf"
strFileName = "C:\Windows\Media\tada.wav"
strSubject = "Your Subject Goes Here"
Set oNotesSession = CreateObject("Notes.Notessession") 'create notes session
Set oDb = oNotesSession.GetDatabase("", "FileStorage.nsf") 'open database on local named FileStorage.nsf
Set oDoc = oDb.CreateDocument
' Filling the fields
oDoc.Subject = strSubject
Set oBody = oDoc.CreateRichTextItem("Body")
oBody.EmbedObject 1454, "", strFileName '1454 = Embedded Attachment type
oDoc.Save False, False

Resources