/ Forums / Advansys Formativ / Creating Solutions with Formativ / Create Find Results Folder

  • Creator
    Topic
  • #4015
    stuartcross
    Participant

      Does anyone know if there is a way to create a find results folder in the GW account using Advansys. We have a request to be able to create a folder called ‘Unopened Items’ which is a find results folder which searches the mailbox for all unopened items.

      Thanks,

      Stuart

    • Author
      Replies
    • #6854
      Support 1
      Participant

        Thank you for your question. Below is a code sample to creates a search results folder that I think matches your requirement.

        '------------------------------------------------------------------------
        Const FOLDER_NAME_QUERY = "Unopened Items"
         
        Sub Main(Client, GWEvent)
         
          dim oQuery
          dim oFolder
         
          call GroupWise.Account.Refresh
         
          On Error Resume Next
        
          set oFolder = GroupWise.Account.RootFolder.Folders.ItemByName(FOLDER_NAME_QUERY)
         
          ' Exit, if the folder is exists
          if IsObject(oFolder) Then
            MsgBox ("The folder '" & FOLDER_NAME_QUERY & "' already exists in your Cabinet. " &_
            "If required, you can rename the existing search folder and run this applet again.")
            exit sub
          end if
         
          ' Creates a new Query object
          set oQuery = GroupWise.Account.CreateQuery
         
          ' Set up a Filter expression.
          oQuery.Expression = "(MAIL) AND (NOT OPENED) AND (BOX_TYPE = INCOMING)"
        
          call oQuery.Locations.Add(GroupWise.Account.Mailbox)
        
          ' Run the query whenever the folder is selected.
          oQuery.StartOnOpen = true
        
          call oQuery.CreateFolder(FOLDER_NAME_QUERY, GroupWise.Account.RootFolder)
          call GroupWise.Account.Refresh
         
          call MsgBox ("The folder '" & FOLDER_NAME_QUERY & "' was created under the root folder.")
         
          set oQuery = Nothing
          set oFolder = Nothing
         
        End Sub
        '------------------------------------------------------------------------

        I hope this helps.

        Advansys Support

        #6858
        stuartcross
        Participant

          This is great. Is there anywhere that I can get documentation on all these expressions etc. I would like the folder to only search the Mailbox. Is there any way of doing this? Also is it possible to force the display to be sortd on date in descending order?

          Thanks,

          Stuart

          #6857
          Support 1
          Participant

            You can find documentation on the Query object here. Novell’s Object API reference also includes Filter Expressions.

            The example applet in my earlier post limits the search to the Mailbox folder (see the Query.Locations property).

            The folder object does not have a ‘sort by’ property. However you can create a Display Settings profile for this folder. On the main GroupWise menu: View | Display Settings > Edit/Create. Sort by date is among the many options available here. I think the administrator also can create a profile which can be shared by multiple users.

            The following example applet applies the predefined profile ‘Test’ to the search folder ‘Unopened Items’.

            const FOLDER_NAME_QUERY = "Unopened Items"
            const SETTINGS_NAME = "Test"
            
            '-------------------------------------------------------------------------------
            ' main-Line processing
            '-------------------------------------------------------------------------------
            Sub Main(Client, GWEvent)
            
              dim oFolder
              dim iSyntax
              dim iFolderPath
            
              set oFolder = GroupWise.Account.RootFolder.Folders.ItemByName(FOLDER_NAME_QUERY)
            
              ' Get the folder path
              call GetFolderPath(oFolder, iFolderPath)
            
              ' Remove the last '' delimiter from the path
              iFolderPath = RemoveTrailingDelimiter(iFolderPath)
            
              if iFolderPath = "" then
                exit sub
              end if
            
              ' Select the 'Unopened Items' folder
              call GroupWise.FolderSelect(iFolderPath)
            
              ' Change the folder settings
              iSyntax = "DisplaySettingsSetEx(""" & iFolderPath & """;""" & SETTINGS_NAME & """)"
            
              if GroupWise.ThrowToken(iSyntax, "") then
                msgbox("Display settings updated.")
              end if
            
              set oFolder = nothing
            
            End Sub
            
            function GetFolderPath(aFolder, aPath)
            
              dim iFolder
            
              if aFolder is nothing then
                exit function
              end if
            
              aPath = aFolder.name & "" & aPath
              if aFolder.ObjType <> fgwRoot then
                set iFolder = aFolder.ParentFolder
                call GetFolderPath(iFolder, aPath)
                set iFolder = nothing
              end if
            
            end function
            
            function RemoveTrailingDelimiter(aPath)
            
              aPath = trim(replace(aPath, "\", ""))
            
              dim iChar
            
              iChar = right(aPath, 1)
              if iChar = "" then
                aPath = mid(aPath, 1, len(aPath) -1)
              end if
            
              RemoveTrailingDelimiter = aPath
            
            end function

            I hope this helps.

            Advansys Support

            #6852
            stuartcross
            Participant

              Thanks again.

              I see what you mean that it searches the Mailbox, however on my system this causes it to search the entire mailbox. I would like to be able to just search the Mailbox folder and not my Cabinet or any other folders. Does this make sense?

              Thanks,

              Stuart

              #6853
              Support 1
              Participant

                Thank you for clarifying the requirement.

                I have tested the sample applet myself, and get the same results that you do. Specifying the folder GroupWise.Account.Mailbox does not affect the Query location!

                We will look into whether this is a bug in the GroupWise Object API, and post an update here as soon as we know more.

                In the meantime, you can change the Find properties of your search folder manually. Right-click on the folder in the GroupWise client, select Properties. On the Find tab, uncheck all the unwanted folders, and leave Mailbox checked.

                I hope this helps.

                Advansys Support

                #6856
                stuartcross
                Participant

                  Thanks for the info. Unfortunately we will be rolling this applet across the organisation and as such it is not feasible to manually change the fodlers it selects. I would be very interested in hearing what you find out about the API.

                  Thanks,

                  Stuart

                  #6855
                  Support 1
                  Participant

                    We will be in touch when we know more about the API behaviour.

                    Advansys Support

                  Viewing 7 replies - 1 through 7 (of 7 total)
                  • You must be logged in to reply to this topic.