Autor Thema: Workspace über Script wechseln  (Gelesen 1239 mal)

Offline mweitzel

  • Junior Mitglied
  • **
  • Beiträge: 88
  • Ich liebe dieses Forum!
Workspace über Script wechseln
« am: 09.05.14 - 07:14:26 »
Hallo,
ich versuche über ein Script den Arbeitsbereich zu wechseln. Dies soll automatisch beim öffnen einer Ansicht erfolgen. Der Name des Arbeitsbereiches leitet sich aus dem Namen des aktuell angemeldeten Users ab.
Leider kommt in Notes die Meldung, dass die ID in diesem Kontext nicht gewechselt werden kann. Die Funktion wird in Queryclose einer Ansicht angestossen.


Function Changeworkspace()
   Dim workspace As New NotesUIWorkspace
   Dim session As New NotesSession
   Dim viewLocations As NotesView
   Dim viewPeople As NotesView
   Dim docLocation As NotesDocument
   Dim docPerson As NotesDocument
   Dim dbNAB As NotesDatabase
   Dim dbPAB As NotesDatabase
   Dim LocationDocument As String
   Dim nnUserName As NotesName
   Dim PersonalAddressBook As String
   Dim MailFile As String
   Dim MailFilePerson As String
   Dim dbCurrent As NotesDatabase
   Set dbCurrent = session.CurrentDatabase
   Dim DateTimeNow As NotesDateTime
   Set DateTimeNow = New NotesDateTime(Now)
   Dim sDateTime As String
   sDateTime = DateTimeNow.LsLocalTime
   
     'Get the personal address book from the notes.ini and remove any cascaded local address books
   PersonalAddressBook = Trim(session.GetEnvironmentString("Names",True))
   If Instr(PersonalAddressBook, ",") > 0 Then
      PersonalAddressBook = Left$(PersonalAddressBook, Instr(PersonalAddressBook, ",") -1)
   Else
      If Instr(PersonalAddressBook, ";") > 0 Then
         PersonalAddressBook = Left$(PersonalAddressBook, Instr(PersonalAddressBook, ";") -1)
      End If
   End If
   
  'Get the personal address book, exit if cannot be opened
   Set dbPAB = session.GetDatabase("", PersonalAddressBook)
           'Set dbPAB = session.GetDatabase("", "names.nsf")
   If dbPAB.IsOpen = False Then Goto FinishFunction
   
  'Get the current location document in use, exit if any errors
   Set viewLocations = dbPAB.GetView("Locations")
   If viewLocations Is Nothing Then Goto FinishFunction
   LocationDocument = Trim(session.GetEnvironmentString("Location",True))
   If LocationDocument = "" Then Goto FinishFunction
   LocationDocument = Left$(LocationDocument, Instr(LocationDocument, ",") -1)
   If LocationDocument = "" Then Goto FinishFunction
   Set docLocation = viewLocations.GetDocumentByKey(LocationDocument)
   If docLocation Is Nothing Then Goto FinishFunction
   
  'Get the Public Address Book from the current server
   Set dbNAB = session.GetDatabase("NOTESSERVER", "names.nsf")
   If dbNAB.IsOpen = False Then Goto FinishFunction
   
  'Get the current users person document. Exit if user not in address book
   Set viewPeople = dbNAB.GetView("($VIMPeople)")
   Set nnUserName = New NotesName(session.UserName)
   Set docPerson = viewPeople.GetDocumentByKey(nnUserName.Abbreviated)
   If docPerson Is Nothing Then Goto FinishFunction
   
  'Get the name of the mail file from the person document and current database
   MailFile = dbCurrent.FilePath
   MailFilePerson = docPerson.MailFile(0)
   If Lcase(Right$(MailFilePerson, 4)) <> ".nsf" Then
      MailFilePerson = MailFilePerson & ".nsf"
   End If
   
   'Change workspace to specified user
   Call workspace.SetCurrentLocation(docPerson.Firstname(0) + " " + docPerson.Lastname(0))
   
FinishFunction:
   
End Function

Offline mweitzel

  • Junior Mitglied
  • **
  • Beiträge: 88
  • Ich liebe dieses Forum!
Re: Workspace über Script wechseln
« Antwort #1 am: 09.05.14 - 07:21:37 »
Habs gefunden. Ich hatte eine Zwangs-ID im Arbeitsbereich, daher wollte er auch beim Bereichswechsel einen ID Wechsel. Wenn das Feld im Arbeitsbereich leer ist geht es.

 

Impressum Atnotes.de  -  Powered by Syslords Solutions  -  Datenschutz