/ Forums / Advansys Formativ / Creating Solutions with Formativ / GroupWise Account CategoryDefinitions Add

  • Creator
    Topic
  • #4351
    dgerisch
    Participant

    If I can generate a name for a new category I want, and put it in strCategoryName, what would I need to add that category to GroupWise?

    Essentially, I want to do:

    GroupWise.Account.CategoryDefinitions.Add(strCategoryName)

    but obviously there is more to it than that.

    Really, I’ve got a StringList that I’m bringing off disk. I want to import the whole list into the GroupWise categories. But if I can do it for one, I can do it for many.

    Thanks!

  • Author
    Replies
  • #7897
    Support 3
    Participant

    Sorry, we are not clear about your question.

    You can create a category using the code you have explained. In regards to creating more then one category, you basically have to execute the code above in a loop. You need to re-start the GroupWise client to refresh the categories collection.

      
      set oList = utilities.stringlist
      oList.add("Test2")
      oList.add("Test3")
    
      for x = 0 to oList.count -1
        GroupWise.Account.CategoryDefinitions.Add(oList.strings(x))
      next
    
      set oList = nothing
    

    Regards,
    Advansys Support

    #7898
    dgerisch
    Participant

    I’m getting an error, and I don’t know why. The error I get is:

    CategoryDefinition.Object
    An invalid argument was passed in the function call. at line 19, column 5

    Sub Main(Client, GWEvent)

    Const CATEGORY_CODE_FILE = “CategoryList.txt”
    DEFAULTFOLDER = Utilities.GetDataDirectory

    iFilePath = DEFAULTFOLDER & CATEGORY_CODE_FILE
    set iCodeList = Utilities.StringList
    set iFSO = CreateObject(“Scripting.FileSystemObject”)

    If iFSO.FileExists(iFilePath) then
    iCodeList.LoadFromFile(iFilePath)
    End if

    For x = 0 to iCodeList.count – 1
    GroupWise.Account.CategoryDefinitions.Add(iCodeList.strings(x))
    Next

    Set iCodeList = Nothing

    End Sub

    Line 19 is the GroupWise.Account.CategoryDefinitions.Add(iCodeList.strings(x)) line.

    I know for certain that the file exists, because if I put a msgbox inside the If iFSO.FileExists(iFilePath) block, I do get a pop up that tells me this test was met.

    I’m guessing that there is something different between a bunch of iCodeList.Add(“”) statements and iCodeList.LoadFromFile(), but I don’t know what it is.

    Thank you for any pointers you can send me.

    #7895
    dgerisch
    Participant

    The plot thickens. After exiting and starting GroupWise again, I did get two categories added. The third line in the file has commas in it though.

    And now, after removing the lines in the file with commas, the whole thing does import, just like I want.

    #7896
    Support 3
    Participant

    Good to hear that you have solved the issue.

    You can also perform some check prior to add the category. For example, set the minimum length of the category to 3 or more characters length.

      
    For x = 0 to iCodeList.count - 1
      if (len(iCodeList.strings(x)) >= 3) then
        GroupWise.Account.CategoryDefinitions.Add(iCodeList.strings(x))
      end if
    Next
    

    Regards,
    Advansys Support

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