code: def handle_AS_wo_category(portal):
      
      uc = getToolByName(portal, 'bika_setup_catalog')
      services = uc(portal_type='AnalysisService', getCategoryUID=None)
      if not services:
          logger.info("SKIPPING. There is no Analysis Service without category.")
          return
  
      # First , create a new 'Uknown' Category, if doesn't exist
      uc = getToolByName(portal, 'uid_catalog')
      acats = uc(portal_type='AnalysisCategory')
      for acat in acats:
          if acat.Title == 'Unknown':
              logger.info("Category 'Uknown' already exists...")
              category = acat.getObject()
              break
      else:
          category = _createObjectByType("AnalysisCategory",
                                         portal.bika_setup.bika_analysiscategories,
                                         tmpID())
          category.setTitle("Unknown")
          category._renameAfterCreation()
          category.reindexObject()
          logger.info("Category 'Unknown' was created...")
  
      counter = 0
      total = len(services)
      for s in services:
          obj = s.getObject()
          obj.setCategory(category)
          obj.reindexObject()
          counter += 1
          logger.info("Assigning Analysis Services to 'unknown' Category: %d of %d" % (counter, total))
  
      logger.info("Done! %d AnalysisServices were assigned to the Category 'unknown'."
                  % counter)
docs: Apparently, some of Analysis Services remained without category after
      migration.
      Creating a new Category ('unknown') and assigning those AS'es to it.