我有一個數據庫保存合同,每個合同都有一個附加的文檔文件。
我的任務是讓沒有訪問數據庫的用戶能夠訪問特定的合同及其附件。
因此,特殊訪問按鈕。
我向表單添加了一個特殊的訪問按鈕,可以訪問默認用戶。
我能夠讓他們訪問合同,但我無法讓他們訪問附加文檔。
經過進一步調查,我發現與附加文檔相關的表單僅限於與角色/讀者,作者和網站管理員一起查看。
我應該做的解決方案是創建一個新角色(addreader)並創建一個具有addreader角色的組。
當通過特殊訪問按鈕添加用戶時,應將用戶添加到具有addreader角色的筆記組中。
我的問題在這裏是如何添加組中的用戶。
我是一名蓮花筆記的初學者,我希望得到一些幫助。
在此先感謝。以編程方式將用戶添加到蓮花筆記組
代碼從這裏開始:
Sub Initialize
AGENT_NAME = "wqs-DocAccess"
ERROR_ON = True
If (ERROR_ON) Then On Error Goto Error_Handler
Call initObjects() ' Set global variables
Call ProcessAccess()
Exit Sub
Error_Handler: ' Error handling
Call ErrorHandler(Err(), Error$(), "Initialize sub", Erl())
End Sub
Sub ProcessAccess()
' This sub will inspect the given effective date range and enforce it for this web submit.
If (ERROR_ON) Then On Error Goto Error_Handler
Dim scanDoc As NotesDocument
Dim nItem As NotesItem
Dim vStart As Variant
Dim vEnd As Variant
Dim vEntries As Variant ' Array of strings
Dim strUser As String
Dim strCanonUser As String
Dim strDESUnid As String
Dim strDuration As String
Dim doRemove As Integer ' Boolean: Default = False
strUser = webDoc.GetItemValue("UserName")(0)
strCanonUser = Session.CreateName(strUser).Canonical
strDESUnid = webDoc.GetItemValue("DesDocID")(0)
If (webDoc.GetItemValue("RemoveAccess")(0) = "Yes") Then doRemove = True
' Determine date range
vStart = webDoc.GetItemValue("AccessBeginDate")(0)
strDuration = webDoc.GetItemValue("Duration")(0)
' Required fields on Access Doc have been filled out - continue inspection
vEnd = Evaluate(|@Adjust([| & Format$(vStart, "mm/dd/yyyy") & |]; 0; 0; | & Val(strDuration) - 1 & |; 0; 0; 0)|)
vEnd = vEnd(0)
' Store info in the event an error occurs trying to retrieve DES
strErrorInfo = "DES UNID = " & strDESUnid & "; User = " & strUser & "; AccessDoc UNID = " & webDoc.UniversalID
' Retrieve DES doc
Set desDoc = getDESDoc(strDESUnid)
If (desDoc Is Nothing) Then
Error 6020, "ERROR: Could not find related DES doc upon saving the Access doc" ' Should never happen.
End If
' Continue inspection of effective date range and be sure is enforced on DES
vEntries = desDoc.GetItemValue("AllowAccess")
If ((Today >= vStart And Today <= vEnd) And (Not doRemove)) Then
' In scope, be sure name and Access UNID are in DES
If Not (isStringInArray(strUser, vEntries)) Then
' User should have access, but is not listed -- stamp name on DES
Call desDoc.ReplaceItemValue("AllowAccess", AddStringToArray(strUser, vEntries))
Call desDoc.ReplaceItemValue("AllowAccessDocID", _
AddStringToArray(webDoc.UniversalID, desDoc.GetItemValue("AllowAccessDocID")))
' Add name to Readers field on DES
Call desDoc.ReplaceItemValue("WhoCanRead", _
AddStringToArray(strCanonUser, desDoc.GetItemValue("WhoCanRead")))
' BSM 09/08/2004: Also add name to Readers field on Scan doc (if one exists)
Set scanDoc = getScanDoc(desDoc)
If Not (scanDoc Is Nothing) Then
Call scanDoc.ReplaceItemValue("WhoCanRead", _
AddStringToArray(strCanonUser, scanDoc.GetItemValue("WhoCanRead")))
Call scanDoc.Save(True, True)
End If
Call StampAccessHistory(desDoc, Format$(Now, "mm/dd/yyyy") & " -- Name added: " & strUser)
Call desDoc.Save(True, True)
End If
Else
' Out of scope, be sure name and Access UNID are *not* in DES
If (isStringInArray(strUser, vEntries)) Then
' ERROR -- User has access, but should not! -- Remove user name stamp from DES.
Call RemoveAccessNameFromDES(strUser, strDESUnid, False)
End If
If (vEnd < Today) Then
Call webDoc.ReplaceItemValue("Expired", "Yes")
End If
' Note: If user clicked "Remove", then the daily agent will delete it the next day (cannot delete webDoc if the DocumentContext)
End If
' Copy editors field over from DES doc
Set nItem = desDoc.GetFirstItem("WhoCanEdit")
Call webDoc.CopyItem(nItem, "")
Exit Sub
Error_Handler: ' Error handling
Call ErrorHandler(Err(), Error$(), "ProcessAccess sub", Erl())
End Sub
Sub initObjects()
' This sub will set certain global variables
If (ERROR_ON) Then On Error Goto Error_Handler
Call InitSession() ' Invoke shared function
Set webDoc = Session.DocumentContext
Exit Sub
Error_Handler: ' Error handling
Call ErrorHandler(Err(), Error$(), "initObjects sub", Erl())
End Sub
我不確定將用戶添加到組是否是解決問題的正確方案。您需要在此澄清一些您的語言,以便我們清楚地瞭解您的真實情況。當你說「附件」時,這可能僅僅意味着一個直接附加到包含合同的Notes文檔的文件。我不認爲你是這個意思,但重要的是要確定。此應用程序是否有兩種形式 - 一種用於合同文件,另一種用於包含附件的文件? –
第二理查茲評論 –
對不起,我無法清楚地討論我的問題。你是對的。文檔附有文檔和文件。我有兩種形式。一種形式來查看合同和另一種形式,用戶可以查看或下載附件。用戶可以下載附件的表單僅限於角色閱讀,作者和siteadmin用戶查看。數據庫已經由開發者設計。 –