I always get the complaints from the user saying being a manager I can't edit the document(s) which are created by other members.I always explain them , This is how Quickplace works.Quickplace shows "Edit" button to Author of the document or for those who are listed as "Additional Editors" section in the document.Yesterday, One of my user asked me to allow all AUTHORS and MANAGERS of the Quickplace to edit all the documents in the Quickplace.It could be only possible if you are writing your own LS code which executes manually or on schedule basis.Here was my solution , which worked fine and user got smile too :)
1- Open the Quickplace in Lotus client (It will depend on your requirement which room
you are going to implement this solution, I assume its main.nsf)
2- Write a LS agent which will take all documents handle from "h_Index" view (h_Index
only shows user documents)
Set view = db.GetView("h_Index")
Set entryColl=view.AllEntries
(I prefer entryCollection Class , Because it gives you better performance)
3- Checking whether document is "Published" or not. We need this checking because we
can't run the code which modify the personal draft documents.
You can use "h_PageCmd" field to check whether document is in draft mode or not.It
may contains three possible values , "h_MakeDraft" , "h_Publish" and
"h_MakeDraftFromPublishedVersion".
If doc.HasItem("h_PageCmd") And (doc.GetItemValue("h_PageCmd")(0)="h_Publish" Or doc.GetItemValue("h_PageCmd")(0)="h_MakeDraftFromPublishedVersion" ) then
4- Next, We have to get document's Author field handle.In my situation, I had
requirement to stamp all authors and managers of the main.nsf ACL.
5- Use NotesACL and NotesACLentry class to make list of desire authors and managers.
6- Update those Authors/Managers list to "h_Authors" fields of the document.
7- Save and close the document , go to the next document handle.
Today while working on one of the requirement my LS agent thrown the warning saying "In order to do multiple transactions simultaneously,you can't use the same db handle".But, Agent execution doesn't effected.I was curious to know why it has happened, I started my agent again to reproduce the warning.I noticed, I haven't disable the view autoupdate property to false, Could be the reason ? Still I don't give assurance to myself ,What went wrong.
Since my code was taking two different database handle , I suspect delay in releasing first database handle might cause the problem.But who knows ?????
But, Such situation can be avoided if its coming frequently with complex code.Here is the possible solution.
1- Disabled view autoupdate property.
2-
In the view's (Globals) section:
Option Public
Use "libSendKeys"
Declare Function GetForegroundWindow Lib "user32" () As Long
Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (Byval hwnd As Long, Byval lpString As String, Byval cch As Long) As Long
Dim nt As NotesTimer
Dim lHwnd As Long
Dim lCurHwnd As Long
Dim sText As String * 255
Sub handler(nt As NotesTimer)
Dim sCurText As String * 255
Dim i As Integer
lCurHwnd = GetForegroundWindow
If lCurHwnd <> lHwnd Then Exit Sub
i= GetWindowText(lHwnd, Byval sCurText, 255)
sCurText= Trim(Left$(sCurText, i))
If sText<>sCurText Then Exit Sub
Print Now
Call PushKeys("{F9}")
End Sub
In the view's (View) section:
Sub Postopen(Source As Notesuiview)
Dim i As Integer
lHwnd = GetForegroundWindow
i= GetWindowText(lHwnd, Byval sText, 255)
sText= Trim(Left$(sText, i))
Print "ActiveWindow: " + sText
Set nt= New NotesTimer(10)
On Event Alarm From nt Call handler
nt.Enabled= True
Print "Enabled"
End Sub