Lotus Notes — рабочий инструмент программиста.

Обсуждения программирования на Lotus Notes/Domino

Archive for Октябрь 12th, 2008

Disable and Cleanup Mail Rules

без комментариев

Add this agent to your Lotus Notes mail template. Ask your user to: – open their mailbox
- click on the Actions menu, and choose "Disable and Cleanup Mail Rules" This will disable all mail rules in the user’s mailbox, and move the user to their Rules folder so they can enable rules as needed.

Original source : http://www.openntf.org/projects/codebin/codebin.ns…

Написано lotusnotes

Октябрь 12, 2008 в 9:33

Опубликовано в Lotus Notes

Change fields position in a flat text file

без комментариев

‘—: Option Declare ‘ ‘ FieldName TAB Length TAB Position ‘ Const FormatFileInput=|
USR-IDAZE 8 36
USR-MAZEAT 7 44
USR-TIAZETRE 4 51
USR-NAZEOM 25 55 | ‘ ‘ FieldName TAB Length TAB Position ‘ Const FormatFileOutput=|
USR-IDAZE 8 501
USR-MAZEAT 7 509
USR-TIAZETRE 4 516
USR-NAZEOM 25 520 | Const FileNameInput = "IN.TXT"
Const FileNameOutput = "OUT.TXT" Type LineFileFormat
Name As String
Length As Long
Position As Long
End Type Type FormatConv
In As LineFileFormat
Out As LineFileFormat
End Type Dim LineOutTotalLength As Long Sub Initialize Dim FormatConvertion List As FormatConv
Dim V As Variant
Dim FormatFile_Tmp As Variant
Dim LineFileFormat_Tmp As LineFileFormat ‘ IN
FormatFile_Tmp = Split( FormatFileInput , Chr$(10) )
Forall Champ In FormatFile_Tmp
V = Split( Champ , Chr$( 9 ) )
If Trim$( V(0) ) <> "" Then
LineFileFormat_Tmp.Name = Trim$( V( 0 ) )
LineFileFormat_Tmp.Length = Val( V( 1 ) )
LineFileFormat_Tmp.Position = Val( V( 2 ) )
FormatConvertion( LineFileFormat_Tmp.Name ).IN = LineFileFormat_Tmp
End If
End Forall ‘ OUT
FormatFile_Tmp = Split( FormatFileOutput , Chr$(10) )
Forall Champ In FormatFile_Tmp
V = Split( Champ , Chr$( 9 ) )
If Trim$( V(0) ) <> "" Then
LineFileFormat_Tmp.Name = Trim$( V( 0 ) )
LineFileFormat_Tmp.Length = Val( V( 1 ) )
LineFileFormat_Tmp.Position = Val( V( 2 ) )
FormatConvertion( LineFileFormat_Tmp.Name ).OUT = LineFileFormat_Tmp
If LineFileFormat_Tmp.Position + LineFileFormat_Tmp.Length > LineOutTotalLength Then LineOutTotalLength = LineFileFormat_Tmp.Position + LineFileFormat_Tmp.Length
End If
End Forall ‘ ‘ Format Control ‘ Forall OneFieldConvertion In FormatConvertion
If OneFieldConvertion.In.Name = "" Then
Print OneFieldConvertion.Out.Name + Chr$(9) + Chr$(9) + " The ouput file do not contains this field"
Elseif OneFieldConvertion.Out.Name = "" Then
Print OneFieldConvertion.In.Name + Chr$(9) + Chr$(9) + " The ouput file do not contains this field"
Elseif OneFieldConvertion.In.Length > OneFieldConvertion.Out.Length Then
Print OneFieldConvertion.In.Name + Chr$(9) + Chr$(9) + " This field size will be reduced to " + Cstr(OneFieldConvertion.Out.Length) + " instead of " + Cstr(OneFieldConvertion.In.Length)
End If
End Forall ‘ ‘ Convertion ‘ Dim FileNumInPut As Long
FileNumInPut = Freefile
Open FileNameInput For Input Access Read As FileNumInPut Dim FileNumOutPut As Long
FileNumOutPut = Freefile
Open FileNameOutput For Output Access Write As FileNumOutPut Dim S As String
Do Until Eof(FileNumInPut)
Line Input #FileNumInPut, S
Print #FileNumOutPut, LineConvert( S , FormatConvertion )
Loop Close #FileNumOutPut
Close #FileNumInPut End Sub Function LineConvert( LineIn As String, FormatConvertion List As FormatConv ) As String Dim S As String Dim LineOut As String
LineOut = Space$( LineOutTotalLength ) Forall AFieldToConvert In FormatConvertion
If (AFieldToConvert.IN.Name <> "") And (AFieldToConvert.OUT.Name <> "") Then
S = Mid$( LineIn , AFieldToConvert.IN.Position , AFieldToConvert.IN.Length )
If Len(S) < AFieldToConvert.OUT.Length Then
S = S + Space$( AFieldToConvert.OUT.Length – Len(S) )
End If
LineOut = Left$( LineOut , AFieldToConvert.OUT.Position-1 ) + Left$( S , AFieldToConvert.OUT.Length ) + Mid$( LineOut , AFieldToConvert.OUT.Position + AFieldToConvert.OUT.Length )
End If
End Forall LineConvert = LineOut End Function

Original source : http://www.openntf.org/projects/codebin/codebin.ns…

Написано lotusnotes

Октябрь 12, 2008 в 9:33

Опубликовано в Lotus Notes

Export all group members in CSV file

без комментариев

Dim FileNum As Long
Dim LogError As String Sub Initialize Dim session As New NotesSession
Dim db As NotesDatabase
Dim collection As NotesDocumentCollection
Dim doc As NotesDocument
Set db = session.CurrentDatabase
Set collection = db.UnprocessedDocuments Set doc = collection.GetFirstDocument()
While Not(doc Is Nothing) Call InitExport( Doc.ListName(0) )
Call GroupExport( Doc.ListName(0) )
Call TerminateExport( ) Set doc = collection.GetNextDocument(doc)
Wend
print LogError
End Sub Sub TerminateExport( ) Close #FileNum End Sub Sub GroupExport( GroupName As String ) Dim Session As New NotesSession
Dim DB As NotesDatabase
Set DB = Session.CurrentDatabase Dim AllUsersView As NotesView
Set AllUsersView = DB.GetView( "($Users)" ) Dim Doc As NotesDocument
Set Doc = AllUsersView.GetDocumentByKey( GroupName , True ) If Doc Is Nothing Then
LogError = LogError + " Groupe/User introuvable : " + GroupName + Chr$(10)
Exit Sub
End If If Doc.Type(0) = "Group" Then Forall OneMember In Doc.Members
GroupExport( OneMember )
End Forall Elseif Doc.Type(0) = "Person" Then Print #FileNum, |"| + Doc.FullName(0) + |"| End If End Sub Sub InitExport( GroupName As String ) FileNum = Freefile() Open "c:\TEMP\Export CSV of " + GroupName + ".CSV" For Output Access Write As FileNum End Sub

Original source : http://www.openntf.org/projects/codebin/codebin.ns…

Написано lotusnotes

Октябрь 12, 2008 в 9:33

Опубликовано в Lotus Notes

Export Selected documents as CSV

без комментариев

Sub Initialize Dim I As Long Dim ExportedFields List As Long
Dim NombreExportedFields As Long Const NomCSVFile = "C:\TEMP\Export.CSV" Dim CSVFile As Long
CSVFile = Freefile() Open NomCSVFile For Output Access Write As CSVFile Dim session As New NotesSession
Dim db As NotesDatabase
Dim collection As NotesDocumentCollection
Dim doc As NotesDocument
Set db = session.CurrentDatabase
Set collection = db.UnprocessedDocuments I=1
Set doc = collection.GetFirstDocument()
While Not(doc Is Nothing) And (I<50) Forall ANotesItem In Doc.Items
If Not Iselement( ExportedFields( ANotesItem.Name ) ) Then
NombreExportedFields = NombreExportedFields + 1
ExportedFields( ANotesItem.Name ) = NombreExportedFields
End If
End Forall I = I +1
Set doc = collection.GetNextDocument(doc)
Wend Redim LigneOut( 1 To NombreExportedFields) As String Forall UC In ExportedFields
LigneOut( UC ) = Listtag( UC )
End Forall Call FlushLineOut( CSVFile , LigneOut ) Set doc = collection.GetFirstDocument()
While Not(doc Is Nothing) Forall ANotesItem In Doc.Items
If Not Iselement( ExportedFields( ANotesItem.Name ) ) Then Error 9995
LigneOut( ExportedFields( ANotesItem.Name ) ) = ANotesItem.Values(0)
End Forall Call FlushLineOut( CSVFile , LigneOut ) Call session.UpdateProcessedDoc( doc )
Set doc = collection.GetNextDocument(doc)
Wend Close #CSVFile End Sub Sub FlushLineOut( FileNum As Long , LigneOut() As String ) Dim i As Long For I = 1 To Ubound( LigneOut ) If I>1 Then Print #FileNum, |;| ; Print #FileNum, |"| + LigneOut( I ) + |"| ; LigneOut( I ) = "" Next I Print #FileNum, "" End Sub

Original source : http://www.openntf.org/projects/codebin/codebin.ns…

Написано lotusnotes

Октябрь 12, 2008 в 9:33

Опубликовано в Lotus Notes

Emailing a subform from the current UI document

без комментариев

I have provided a sample database with this utility at: http://www.openntf.org/Projects/pmt.nsf/HomeLookup/97CEA8C9251DA3BE862574A2006FA7B8?OpenDocument Emailing a subform from the current UI document I’m sure most of you are familar with the simple @Command([MailForward]) function. @Command([MailForward]) forwards the current document by placing its entire contents into a mail memo which the user then addresses and sends. I was tasked with duplicating this functionality, but for a subform on the current document. Futhermore, the customer wanted to the memo to be executed through the backend and sent via the click of a button. Approach: The key to this accomplishing this task is to isolate the subform in its own form. After the subform isolated, its entire contents can be copied to the clipboard, pasted it into a rich text field, and sent to a specified user. Follow these 3 steps to create the basic forms and code for this utility. Step 1: a.) Create a hotspot button on the subform you wish to email and add this code to the ‘click’ event: (note: In the ‘hide-when’ options of the hotspot button, check the box for hiding when "Copied to the Clipboard") ‘This button will switch the form name of the current document and open the document using the temp form. Dim strOrgForm As String
Dim ws As New NotesUIWorkspace
Set doc = ws.CurrentDocument.Document
Let strOrgForm = doc.Form(0) ‘capture the original form name
doc.ReplaceItemValue "Form", "TempForm" ’switch the form to the temp ‘email’ form. Call ws.EditDocument(False,doc) ‘reopen the document with the ‘temp’ form. doc.ReplaceItemValue "Form", strOrgForm ‘replace the form name back to its original name. —————————————————————————————– Step 2: a.) Create a form in your database and name it "TempForm". b.) Insert the subform from Step 1 into "TempForm"
c.) (optional: If your underlying original form as richtext fields with attachments, add those richtext fields on the tempform in a hidden section. The section must be hidden and the section properties must be set to ‘auto-collapse’ on open. Otherwise the attachments from the main form will appear at the bottom of the email when it is sent. This step is not necessary if your underlying form does not have rich text fields.)
d.) copy and paste the following code into the "PostOpen" event the "TempForm" subform. Dim db As NotesDatabase
Dim ns As New NotesSession
Dim uidoc As NotesUIDocument
Dim docMemo As NotesDocument
Dim ws As New NotesUIWorkspace
Dim ndt As New NotesDateTime("12/31/1899") ‘The postopen event will copy the entire unhidden contents of the form to the user’s clipboard
‘Then it will grab the memo document saved in the database and open it. Set db = ns.CurrentDatabase
Set uidoc = ws.CurrentDocument
Call uidoc.SelectAll
Call uidoc.Copy
Call uidoc.Close Set dcMemo = db.Search(|Form = "Memo"|,ndt,1) ‘Get the Memo document in database. There should only be 1 memo document
If dcMemo.Count = 0 Then ‘If the memo document is not created, than create a new one
‘This code will only execute the first time someone uses this utility. Set docMemo = New NotesDocument(db)
docMemo.ReplaceItemValue "Form", "Memo"
Else
Set docMemo = dcMemo.GetFirstDocument ‘otherwise just get the existing memo document
End If ‘In this example we are sending the subform to the current user. docMemo.ReplaceItemValue "SendTo", ns.CommonUsername
‘If you wish to make the sendto field variable, add a hidden field to the tempform Form, popluate it, and then reference it here like this: ‘docMemo.ReplaceItemValue "SendTo", uidoc.Document.GetFirstItem(your fieldname goes here).Values
docMemo.ReplaceItemValue "CopyTo", "" ‘Add more people to CC if desired
docMemo.ReplaceItemValue "Subject", "Test: Emailing a subform" ‘add a subject to your memo
docMemo.ReplaceItemValue "Body", "" ‘clear the body field each time before opening the memo
Call ws.EditDocument(True,docMemo) ‘Open the Memo document. ———————————————————————————————— Step 3: a.) Create a form in your database and name it "Memo"
b.) Create an editable rich text field on the Memo Form and name it "Body". c.) copy and paste the following code into the "PostOpen" event the "TempForm" subform. Dim uidoc As NotesUIDocument
Dim ws As New NotesUIWorkspace ‘The postopen event of this form will paste the contents of the user’s clipboard into the body field
Set uidoc = ws.CurrentDocument
Call uidoc.Paste ‘paste the subform into the body field of the uidoc (body field is default focus)
Call uidoc.Save ‘the uidoc must be saved to capture the rich text
Call uidoc.Document.Send(False,False) ’send the memo document
Call uidoc.Close

Original source : http://www.openntf.org/projects/codebin/codebin.ns…

Написано lotusnotes

Октябрь 12, 2008 в 9:33

Опубликовано в Lotus Notes

Modification of Michael Woehrer’s History Class to show new values

без комментариев

This is an example of how Michael Woehrer’s [<a href="http://www.openntf.org/Projects/codebin/codebin.nsf/0/71E930683C3401A3C1256F2F00611BAA">History Class</a>] can be modified to track the new value as well as the old value.

Original source : http://www.openntf.org/projects/codebin/codebin.ns…

Написано lotusnotes

Октябрь 12, 2008 в 9:33

Опубликовано в Lotus Notes

Connect Server Agent to Restricted File Share with Alternate UserName/Password

без комментариев

So the SQL Server guy stop by and says, "Hey, we want to create some reports of Notes data and we only know how to use SQL Server to do it. Do you mind exporting it to a delimited text file and saving it to this restricted folder on the file server? Here’s the username and password of a special Windows account with rights to the folder. Oh, and we need it to run on a scheduled basis so everything is automated. Thanks!" The key here is the use of an alternate username and password to gain access to a restricted folder on a Windows file server. Note: This only works on Domino servers running on Windows. Read more: http://www.lotusguru.com/lotusguru/LGBlog.nsf/d6plinks/20080530-7F5HBT

Original source : http://www.openntf.org/projects/codebin/codebin.ns…

Написано lotusnotes

Октябрь 12, 2008 в 9:33

Опубликовано в Lotus Notes