• Creator
    Topic
  • #5124
    dgerisch
    Participant

      I’m trying to make an app to replace one category with another. I can add the second category easily enough; but how would I remove the original one?

      Thanks!

    • Author
      Replies
    • #9846
      Support 1
      Participant

        Thanks for your question.

        You can use the Delete method on a CategoryDefinition object. Probably you would identify the CategoryDefinition by its Name property, as in the (untested) sample below:

        dim iFound, iIndex
        dim oGWAccount, oDef, oDefs
        
        set oGWAccount = Client.ClientState.CurrentAccount
        set oDefs = oGWAccount.CategoryDefinitions
        
        iIndex = 1
        iFound = false
        do while (iIndex <= oDefs.Count) and (not iFound)
          set oDef = oDefs.Item(iIndex)
          if oDef.Name = "Category to remove" then
            iFound = true
            oDef.Delete()
          else
            iIndex = iIndex + 1 
          end if
        loop
        

        This API reference may be helpful: CategoryDefinition

        Kind regards,
        Advansys Support

        #9847
        dgerisch
        Participant

          Sorry – upon review, I completely missed asking the question I needed to ask.

          I need to remove a Category assigned to an Item.

          Set oMsg = Client.ClientState.CommandMessage

          Works fine:

          oMsg.Categories.add(aCategory)

          I have no idea of what the corresponding removal code looks like. The GroupWise developer documentation is pretty opaque about what can be done and how.

          #9848
          Support 3
          Participant

            See the Object API documentation for more information, specially Mail & Message object.

            Sample code below should remove first category from the message.

              
                dim oMsg
                dim oCategory
            
                Set oMsg = Client.ClientState.CommandMessage
            
                if (oMsg.Categories.count > 0) then
                  msgbox "Total categories assigned to the message: " & oMsg.Categories.count
            
                  ' Access first category
                  set oCategory = oMsg.Categories.item(1)
                  msgbox "Removing first category: " & oCategory.Name
            
                  ' Remove the category
                  oCategory.Delete()
            
                  ' You may need to refresh the message. Category removed from the message but client may not refreshed.
                  ' Refresh: Forces this message and associated objects and collections to reread property values from the message database.
                  oMsg.Refresh()
            
                  set oCategory = nothing
            
                end if
            
                set oMsg = nothing
            

            Regards,

            Advansys Support

            #9849
            dgerisch
            Participant

              Thank you very much! That works just like it should. Smile

              Interestingly, one has to close the item view and re-open it to see the change in the Personalize tab.

              #9850
              Support 3
              Participant

                Great, thanks for letting us know and glad it was of assistance.

                Yes, there is some known GroupWise issue of refreshing view when category updated.

                You can post a message in GroupWise forums, hopefully Novell will review this.

                Regards,

                Advansys Support.

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