2013-05-20 27 views
0

我有一個表單,其中有一個批准和拒絕按鈕。這些按鈕僅在文檔處於編輯模式時纔會顯示。消息顯示 - 詢問是否要保存文檔 - 不應該顯示用lotuss寫成的lotus筆記

文檔將處於「等待管理員批准」狀態,用戶按下「批准」按鈕,並詢問他們是否要保存更改。如果他們回答「是」,則更改將被保存,如果他們回答「否」,文檔將關閉,並且如果他們回答「取消」,用戶將被帶回文檔,就像他們按下批准按鈕時一樣。

這是我的問題,當文檔是「等待經理批准」,並且用戶按下「否​​」時,文檔會自動關閉。當文檔移至工作流程的下一步 - 「等待銷售審批」時,用戶按下「審批」按鈕,然後按否與上一步驟相同,但不會自動關閉 ,因爲應該向用戶呈現第二條消息詢問他們是否要保存文檔。

我已經看過代碼,並在「批准」按鈕中使用以下腳本,並且子窗體或窗體上的查詢關閉事件中都沒有任何內容。

任何人都可以告訴我爲什麼消息顯示在工作流的第二步?我不希望消息顯示,因爲用戶回答「否」。

以下是批准按鈕的代碼。在LotusScript中

代碼按鈕:

Sub Click(Source As Button) 
     Dim workspace As New NotesUIWorkspace 
     Dim askme As Integer 
     Dim tellme As Integer 
     Dim holdValue As String 
     Dim holdValue2 As String 
     Dim uidoc As NotesUIDocument 
     Dim doc As NotesDocument 
     Dim boxType As Long, answer As Integer 
     boxType& = MB_YESNOCANCEL + MB_ICONQUESTION 
     Set uidoc = workspace.CurrentDocument 

     Set doc = uidoc.Document   
     Dim num As Integer 


     If (uidoc.EditMode = True) And (DocWasSaved = False) Then 
       holdvalue = uidoc.EditMode       
       askMe = Messagebox("Do you wish to continue?", boxType&, "Continue?") 
       Select Case askme 

       Case 2 
         'Equals Cancel response - no action - goes back into document.   
       Case 6   
         'Equals Yes response - saves document     
         Call uidoc.FieldSetText("Action", "Approve")     
         Call uidoc.FieldSetText("PostAction", "Approve") 
         Call uidoc.FieldSetText("SaveOptions", "1") 
         Call uidoc.FieldSetText("CloseFlag", "Yes")         
         Call uidoc.Save         
         Call uidoc.close       
       Case 7 
         'User answered No, doesn't save and closes document. 
         Call uidoc.Close       
       End Select 
     Else       
     End If   

End Sub 
+0

FYI:這個問題是以前由lnotes-1郵件列表在同一海報問,也已經有解答了。 –

+0

案例7 調用uidoc.FieldSetText(「SaveOptions」,「0」) 調用uidoc.Close(true) – Ramkumar

回答

2

你可以嘗試使用SaveOptions場壓制的「你想保存這個文件?」的另一個對話框。將字段值設置爲「0」可以在沒有提示的情況下關閉文檔。有關更多信息,請參閱this article

所以您的代碼示例將類似於此:

Call uidoc.Save 
Call uidoc.FieldSetText("SaveOptions", "0") 
Call uidoc.Close 
+0

我同意你的方法來解決問題,但是不應該在調用save之前設置saveoptions字段? +1 – giulio

+0

@giulio:是的,你說得對。但它已經在問題中被設定了,所以我沒有在答案中加入。 :) – Naveen

0

而是與SaveOpetions場搞亂的,你也可以讓在後臺的變化,在關閉文檔後。請記住,如果表單上的任何字段已被修改/更改,您將獲得該提示。這就是爲什麼我會建議uidoc.Save()即使取消也是如此。

這裏是我的(未經測試)代碼:

Sub Click(Source As Button) 
Dim ws As New NotesUIWorkspace 
Dim uidoc As NotesUIDocument 
Dim doc As NotesDocument 
Dim result As Integer 
Dim boxType As Long 

boxType = MB_YESNOCANCEL + MB_ICONQUESTION 
Set uidoc = workspace.CurrentDocument 

result = Messagebox("Do you wish to continue?", boxType, "Continue?") 
Select Case result 
Case 2 
    'Equals Cancel response - no action - goes back into document. 
Case 6 
    'Equals Yes response - saves document and closes it 
    Call uidoc.Save() 
    set doc = uidoc.Document 
    Call uidoc.Close(True) 
    Call doc.ReplaceItemvalue("Action", "Approve") 
    Call doc.ReplaceItemvalue("PostAction", "Approve") 
    Call doc.ReplaceItemvalue("SaveOptions", "1") 
    Call doc.ReplaceItemvalue("CloseFlag", "Yes") 
    Call doc.Save(True,False) 
Case 7 
    'User answered No, doesn't save and closes document. 
    'Note: If any field has changed, the user will get the save yes/no prompt. 
    'I would add: 
    'Call uidoc.Save() 
    Call uidoc.Close 
End Select 

End Sub