Function CheckForPendingTask(session As NotesSession, db_dskmgr As NotesDatabase, doc_user As NotesDocument, key_user As String, shortkey_user As String, doc_setup As NotesDocument, run_as_local As Integer) As Integer Dim view_task As NotesView Dim view_task_multi As NotesView Dim view_task_multi_responses As NotesView Dim col As NotesDocumentCollection Dim doc_task_multi As NotesDocument Dim doc_task As NotesDocument Dim start_dateTime As New NotesDateTime("") Dim task_dateTime As NotesDateTime Dim item As NotesItem Dim found As Integer Dim already_done As Integer Dim doc_task_key As String Dim doc_task_shortkey As String Dim abbreviate_fullname As String Dim i As Integer Dim t As Integer Dim c As String Dim short_key As Integer Dim has_already_ran As String Dim task_date As String Dim is_allowed As Integer ' # Init abbreviate_fullname = GetAbbreviateName(session.UserName) ' ## Look for Muti-Users Tasks Set view_task_multi = db_dskmgr.GetView("(DskMgrTaskMultiKey)") If (view_task_multi Is Nothing) Then Goto PROCESS_TASK Set doc_task_multi = view_task_multi.GetFirstDocument While Not (doc_task_multi Is Nothing) ' # Check if it is the right time to process the Task Call start_dateTime.SetNow If Cstr(doc_task_multi.TASK_ExecutionDate(0)) <> "" Then Set item = doc_task_multi.GetFirstItem("TASK_ExecutionDate") Set task_dateTime = item.DateTimeValue If task_dateTime.TimeDifference(start_dateTime) > 0 Then Goto NEXT_TASK End If ' ## Check if this Task has a conditional launch is_allowed = IsTaskProfileAllowed(session, doc_task_multi, "TASK", doc_user, doc_setup) If is_allowed = 0 Then Goto NEXT_TASK ' # Check if this Task is Full Mode only If doc_task_multi.TASK_RunFullMode(0) = "1" Then Goto NEXT_TASK ' # Check to see if user is audience for this Task found = 0 Forall n In doc_task_multi.TASK_FullName ' # All User If Ucase(Cstr(n)) = "@ALL" Then found = 1 Exit Forall End If ' # Profile Name Forall p In doc_user.Profile If Ucase$(Cstr(p)) = Ucase$(Cstr(n)) Then found = 1 Exit Forall End If End Forall ' # User Name : Full Key If Ucase$(key_user) = Ucase$(Cstr(n)) Then found = 1 Exit Forall End If ' # User Name : Short Key If doc_user.ShortKey(0) = "1" Then doc_task_key = Cstr(n) doc_task_shortkey = GetShortKey (doc_task_key) If doc_user.ShortKey(0) = "1" And (Ucase$(doc_task_shortkey) = Ucase$(shortkey_user) Or Ucase$(doc_task_key) = Ucase$(abbreviate_fullname))Then found = 1 Exit Forall End If End If ' # User Full Name (or abbreviate) If Ucase$(session.UserName) = Ucase$(Cstr(n)) Or Ucase$(abbreviate_fullname) = Ucase$(Cstr(n)) Then found = 1 Exit Forall End If End Forall ' ### Check to see if this Multi User Task has already been processed by this user If found = 1 Then already_done = 0 has_already_ran = HasTaskMultiAlreadyRan(doc_task_multi, doc_user, run_as_local) If has_already_ran = 1 Then Goto NEXT_TASK ' ## Search for Child document If doc_user.DM_LogTaskMessage(0) = "" Then If (view_task_multi_responses Is Nothing) Then Set view_task_multi_responses = db_dskmgr.GetView("(DskMgrTaskMultiResponses)") If (view_task_multi_responses Is Nothing) Then Goto PROCESS_TASK Set col = view_task_multi_responses.GetAllDocumentsByKey(doc_task_multi.UniversalID,True) For t = 1 To col.Count Set doc_task = col.GetNthDocument(t) doc_task_key = doc_task.TASK_FullName(0) ' # We build the short key if needed If doc_user.ShortKey(0) = "1" Then doc_task_shortkey = GetShortKey (doc_task_key) End If ' # Full Key If Ucase$(doc_task_key) = Ucase$(key_user) Then already_done = 1 Exit For End If ' # Short Key If doc_user.ShortKey(0) = "1" And (Ucase$(doc_task_shortkey) = Ucase$(shortkey_user) Or Ucase$(doc_task_key) = Ucase$(abbreviate_fullname)) Then already_done = 1 Exit For End If ' # User Full Name (or abbreviate) If Ucase$(session.UserName) = Ucase$(doc_task_key ) Or Ucase$(abbreviate_fullname) = Ucase$(doc_task_key) Then already_done = 1 Exit For End If Next End If ' # This Multi User Task is Pending If already_done = 0 Then CheckForPendingTask = 1 Exit Function End If End If NEXT_TASK : Set doc_task_multi = view_task_multi.GetNextDocument(doc_task_multi) Wend PROCESS_TASK : ' ### Process Single User Task Set view_task = db_dskmgr.GetView("(DskMgrTaskKey)") If view_task Is Nothing Then CheckForPendingTask = 0 Exit Function End If Set col = view_task.GetAllDocumentsByKey(abbreviate_fullname,True) ' ## Process All Single User Tasks For t = 1 To col.Count Call start_dateTime.SetNow Set doc_task = col.GetNthDocument(t) doc_task_key = doc_task.TASK_FullName(0) ' # Check if this Task is Full Mode only If doc_task.TASK_RunFullMode(0) = "1" Then Goto NEXT_SINGLETASK ' # Full Name If Ucase$(doc_task_key) = Ucase$(session.UserName) Then Goto CHECK_SINGLETASK If Ucase$(doc_task_key) = Ucase$(abbreviate_fullname) Then Goto CHECK_SINGLETASK ' # User Key If Ucase$(doc_task_key) = Ucase$(key_user) Then Goto CHECK_SINGLETASK ' # Check if this Task is for the User If doc_user.ShortKey(0) = "1" Then doc_task_key = doc_task.TASK_FullName(0) ' # Short Key doc_task_shortkey = GetShortKey (doc_task_key) If Ucase$(doc_task_shortkey) = Ucase$(shortkey_user) Then Goto CHECK_SINGLETASK End If ' # Still this user ? If Ucase$(Left$(doc_task_key,Len(abbreviate_fullname))) <> Ucase$(abbreviate_fullname) Then CheckForPendingTask = 0 Exit Function End If ' # Not valid Goto NEXT_SINGLETASK CHECK_SINGLETASK : ' ## Check Execution Date ## If Cstr(doc_task.TASK_ExecutionDate(0)) <> "" Then Set item = doc_task.GetFirstItem("TASK_ExecutionDate") Set task_dateTime = item.DateTimeValue If task_dateTime.TimeDifference(start_dateTime) > 0 Then Goto NEXT_SINGLETASK End If ' ## Check if this Task has a conditional launch is_allowed = IsTaskProfileAllowed(session, doc_task, "TASK", doc_user, doc_setup) If is_allowed = 0 Then Goto NEXT_SINGLETASK ' ## This Task will run => Turn into Full Mode CheckForPendingTask = 1 Exit Function NEXT_SINGLETASK : Next ' No pending Tasks CheckForPendingTask = 0 End Function