2 Replies Latest reply on Jul 19, 2013 10:36 AM by Jamie Cannon

    How to search through all items in a list

    Stephen_Justice Rookie



      So I've been making a new Change Management system for our organisation.


      At one stage the user needs to enter in what Configuration Items are affected by their change. This is done through a collection as the items are imported from a different database.


      As the person adds each item, I then have a script that grabs the names of each one and puts it into a field (String -1) on the main window.


      The items also come with a code to say what items they might affect.


      I would like to have the script run a loop to go through each item in a list to see what matches that code so it can add it to the field on the main window.


      I have tried with a reference list, however it doesn't seem to allow a loop to just search through each reference item for a match.


      Here's an example of what I tried:


      import System

      static def GetAttributeevalue(Change):

      txtCIID = " "

      if Change._ConfigurationItems.Count == 0

        Value = String.Format("No Configuration Items Selected")


        Value = String.Format("The following Configuration Items have been selected:\n\n")

        for item in Change._ConfigurationItems:

         txtCIID = item._CIID

         Value += String.Format("Configuration Items: {0}", item._Name)

         for record in Change._ImpactedCIs:

          if txtCIID == record._LINKTABLE1RECORDID:

           Value += String.Format("\n\tImpacted Configuration Item: {0}", record._CINAME1)

          Value += String.Format("\n\n")

      return Value

      This works fine if I don't include the part to check aginst the Change._ImpactedCIs reference list. When I do include it the error log returns the following line:

      "Cannot enumerate null."


      Any ideas?